Menu

xDaily - A Complete System Updater

cavy

Simply put, it is a semi automatic command line system updater that will also upgrade the system, by opening a terminal and type in sudo xDaily enter your password when prompted, it will clean out your cache, trim a SSD, update your icon cache and autoremove old repos, you be prompted by the Y/N option during the process. If there is a newer kernel version remember to reboot your computer.

Create a new text file in the /usr/local/bin folder and name this file xDaily.

The easiest method is right-click in this directory for the right-click menu, then click on Open as Root enter your password when prompted and navigate to usr/local/bin , there create an Empty Document from the right-click menu, then copy and paste the script below to the blank file then save this file as xDaily .

Remember to check the permission page and activate by placing a tick , where you see Execute: Allow executing file as programme in its tick-box for this file to run as a programme.

This is the latest version of xDaily with specific PeppermintOS tool syncing and system upgrades, the legacy version were intended for HDD and SSD, both are still available by scrolling to the bottom of this page.

#!/bin/bash

PROGNAME="xDaily"
[ "$USER" != "root" ] && 
   echo -e "\t$PROGNAME must be run as root. \n\tOr with \`sudo $PROGNAME\` ." && exit
#use the utils for the needed functions
source /opt/pypep/peputils.sh

### Our options are going to be
#    = "full output to the terminal, no stopping."
# -i = "interactive"
# -q = "interactive but suppressed output"
OPTIND="0"
for i in  _quiet _interactive ; do unset -v $i ; done

while getopts 'iq' OPTION; do
    case "$OPTION" in
      i)
    _interactive="yes"
    echo -e " Entering interactive mode\n"
    break
      ;;

      q)
    _quiet="yes"
    echo -e " Entering interactive mode, without verbose output.\n"
    break
      ;;

      ?)
    echo "Usage: $(basename ${PROGNAME}) [-i = interactive] [-q = suppressed ouput]"
    return 1
      ;;
  esac
done

see_it() {
    [ "$_interactive" = "yes" ] && ( read -n1 -p " $_msg ? \"Y/n\" " answ
    [ -z $answ ] || [ "$answ" = "y" ] || [ "$answ" = "Y" ] && echo &&
    do_it &&
    echo -e " $_msg - Completed.\n" ||
    echo -e "\r $_msg - Skipped.\n" )
}

no_see() {
    [ "$_quiet" = "yes"       ] && ( read -n1 -p " $_msg ? \"Y/n\" " answ
    [ -z $answ ] || [ "$answ" = "y" ] || [ "$answ" = "Y" ] && echo &&
    do_it > /dev/null &&
    echo -e " $_msg - Completed.\n" ||
    echo -e "\r $_msg - Skipped.\n" )
}

run_it() {
    [ "$_interactive" != "yes" ] && [ "$_quiet" != "yes" ] && (
    echo -e "\n $_msg ." &&
    do_it &&
    echo -e " $_msg - Completed." )
}

# Begin xDaily command functions 
_update() {
      _msg="Check for Updates"
      do_it() { 
        [ "$_quiet" != "yes" ] &&
        apt update        ||
        apt update 2>&1 >/dev/null
}
    see_it
    no_see
    run_it
}

_upgradable() {
      _msg="See upgradable packages"
      do_it() {
        [ "$_quiet" != "yes" ] &&
        apt list --upgradable  ||
        apt list --upgradable 2>&1 >/dev/null
}
    see_it
#   no_see
#   run_it
}

_upgrade() {
      _msg="Install available Updates"
      do_it() {
        [ "$_quiet" != "yes" ] &&
        apt upgrade       ||
        apt upgrade 2>&1 >/dev/null
}
    see_it
    no_see
    run_it
}

_apt_clean() {
      _msg="Remove all unavailable entries from APT"
      do_it() {
        [ "$_quiet" != "yes" ] &&
        apt clean         ||
        apt clean 2>&1 >/dev/null
}
    see_it
    no_see
    run_it
}

_autoclean () {
      _msg="Remove unavailable entries from APT"
      do_it() {
        [ "$_quiet" != "yes" ] &&
        apt autoclean     ||
        apt autoclean 2>&1 >/dev/null
}
    see_it
    no_see
    run_it
}

_autoremove() {
      _msg="Remove old dependencies not required by the system"
      do_it() {
        [ "$_quiet" != "yes" ] &&
        apt autoremove    ||
        apt autoremove 2>&1 >/dev/null
}
    see_it
    no_see
    run_it
}

_clear_thumbnails() {
      _msg="Clear thumbnail caches"
      do_it() {
        for i in ".thumbnails" ".cache/thumbnails" ; do
           for j in "*/*.png" "*/*/*.png" ; do
            [ "$_quiet" != "yes" ]  &&
            rm -v /home/${SUDO_USER}/${i}/${j} 2>/dev/null ||
                rm /home/${SUDO_USER}/${i}/${j} 2>/dev/null
           done
        done ; true
          }
    see_it
    no_see
    run_it
}

_clear_recents() {
      _msg="Clear the Recently Used list in FireFox"
      do_it() {
        dd bs=1 count=1 status=none if=/dev/null of=/home/${SUDO_USER}/.local/share/recently-used.xbel
        chown ${SUDO_USER} /home/${SUDO_USER}/.local/share/recently-used.xbel
}
    see_it
    no_see
    run_it
}

_rbranding() {
      _msg="Check & Restore Peppermint Branding in os-release"
      do_it() {
        diff -q /opt/pepconf/os-release /usr/lib/os-release || cp /opt/pepconf/os-release /usr/lib/os-release
        diff -q /opt/pepconf/os-release /etc/os-release     || cp /opt/pepconf/os-release /etc/os-release
          }
    see_it
    no_see
    run_it
}

_ssd_trimfs() {
      _msg="For SSDs: trim eligible ext2/3/4 filesystems"
      do_it() {
        for mnt in $(grep -E "(ext2|ext3|ext4)" /etc/mtab | cut -f2 -d" ")
            do fstrim ${mnt} &>/dev/null &&
            echo -e " Completed fstrim for \"${mnt}\"" ||
            echo -e " No fstrim required for \"${mnt}\""
            done
          }
        see_it
        no_see
        run_it
}

_ptools() {
      _msg="Synch up the PepTools"
      do_it() {
        if [ -d "$pdir" ]
           then fwt
           else fwnt
        fi
          }
       see_it
       no_see
       run_it
}

_udcache() {
      _msg="Caching icons at /usr/share/icons/"
      do_it() { update-icon-caches /usr/share/icons/* ;}
        see_it
        no_see
        run_it
}


_update
_upgradable
_upgrade
_apt_clean
_autoclean 
_autoremove
_clear_thumbnails
_clear_recents
_udcache
_rbranding
_ssd_trimfs
_ptools

Legacy usage
Choose the appropriate text-body for your disk, either HDD or SSD. This can used on any distro to simplify the update process.

For HDD

#! /bin/bash  
sudo apt update
sudo apt upgrade
sudo apt autoclean && sudo apt autoremove
sudo apt clean
rm -v -f ~/.cache/thumbnails/*/*.png ~/.thumbnails/*/*.png
rm -v -f ~/.cache/thumbnails/*/*/*.png ~/.thumbnails/*/*/*.png
cat /dev/null > ~/.local/share/recently-used.xbel
diff -q /opt/pepconf/os-release /usr/lib/os-release || sudo cp -a /opt/pepconf/os-release /usr/lib/os-release
diff -q /opt/pepconf/os-release /etc/os-release || sudo cp -a /opt/pepconf/os-release /etc/os-release
sudo update-icon-caches /usr/share/icons/*

For SSD

#! /bin/bash  
sudo apt update
sudo apt upgrade
sudo apt autoclean && sudo apt autoremove
sudo apt clean
rm -v -f ~/.cache/thumbnails/*/*.png ~/.thumbnails/*/*.png
rm -v -f ~/.cache/thumbnails/*/*/*.png ~/.thumbnails/*/*/*.png
cat /dev/null > ~/.local/share/recently-used.xbel
diff -q /opt/pepconf/os-release /usr/lib/os-release || sudo cp -a /opt/pepconf/os-release /usr/lib/os-release
diff -q /opt/pepconf/os-release /etc/os-release || sudo cp -a /opt/pepconf/os-release /etc/os-release
sudo fstrim -v /
sudo update-icon-caches /usr/share/icons/*

If you have a separate /home or any other scheme add it after the sudo fstrim -v / command, with sudo fstrim -v /home etc.

Upon booting into your computer type xDaily into the terminal and enter your password when prompted, takes a few moments and you have updated with a system clean, to keep computer as fresh as a daisy and good health.

Edit 1 April 2022

To counter the Debian point release which occurred with version 11.3 overwriting the boot entry from PeppermintOS to Debian, I have added the two lines of text to prevent from occurring again. A large thank you to KsWoodsMan, tracking this down and rectify this annoying issue.

Edit 14 May 2022

It has been decided to add the Update the Icon Cache to xDaily as this helps to reduce the overall memory usage of your system.

Edit 29 July 2022

The original versions with their updates are distro agnostic and now considered legacy versions due the ongoing upgrades to the present programme are PeppermintOS specific and need to be identified as such.