User Tools

Site Tools


pages:howtos:tmux:runnig_updates_in_tmux

Running Updates In TMUX

I want to make updates to be executed inside a tmux-session to make the update process resilient against interrupted ssh-connections.

  • update distribution packages on SUSE and Debian
  • update git repositories
  • update flatpak packages
  • update snap packages (it seems like snaps will get updated automatically)

Sources

ToDo

Implementation

zypper in lsb-release


install -bD --owner=root --group=root --mode=0750 -T <(cat << 'EOF'
#!/bin/bash
  
# debug
#set -x
 
declare _updatecommand
declare _flatpak_updatecommand
declare _gitup_user_updatecommand
declare _osvendor
declare _highlevelpackagemanager
declare _os_updatecommand
 
_flatpak_updatecommand="flatpak --system update -y"
_gitup_user_updatecommand="sudo -u def python3.8 /home/def/.local/bin/gitup"
  
if [ ! command -v lsb-release >/dev/null 2>&1 ] && [ ! command -v lsb_release >/dev/null 2>&1 ] 
then 
    echo >&2 "ERROR: lsb-release required but it's not installed.  Aborting."
    exit 1;
fi
  
_osvendor="$( lsb-release -is )"
  
  
case $_osvendor in
    openSUSE)
        _highlevelpackagemanager="$( command -v zypper )"
        _os_updatecommand="${_highlevelpackagemanager} ref && ${_highlevelpackagemanager} dup"
        ;;
          
    Debian)
        _highlevelpackagemanager="$( command -v apt )"
        _os_updatecommand="${_highlevelpackagemanager} update && ${_highlevelpackagemanager} -y upgrade && ${_highlevelpackagemanager} -y full-upgrade"
        ;;
  
    *)
        echo >&2 "ERROR: Your operating system (${_osvendor}) is not supported. Aborting."
        exit 1
        ;;
esac
 
_updatecommand="${_flatpak_updatecommand} && ${_gitup_user_updatecommand} && ${_os_updatecommand}"
 
tmux new -s sysupdate -d
tmux send-keys -t sysupdate "${_updatecommand}" C-m
tmux attach -t sysupdate
EOF
) /root/scripts/sysupdate/sysupdate

ln -s /root/scripts/sysupdate/sysupdate /root/bin/AAA

# as user
su - <USERNAME>
mkdir -pv ~/repos/extern/
git clone https://github.com/earwig/git-repo-updater.git ~/repos/extern/git-repo-updater
cd ~/repos/extern/git-repo-updater
python ./setup.py install --user
add ~/.local/bin to your PATH
vim ~/.bashrc
# PATH
export PATH="${PATH}:~/bin:~/.local/bin"
source  ~/.bashrc
gitup --add ~/repos/

# as root
install -bD --owner=root --group=root --mode=0750 -T <(cat << 'EOF'
[Unit]
Description=Update Flatpak
After=network-online.target
Wants=network-online.target

[Service]
Type=oneshot
ExecStart=/usr/bin/flatpak update --noninteractive --assumeyes

[Install]
WantedBy=multi-user.target
EOF) /etc/systemd/user/flatpak-update.service

install -bD --owner=root --group=root --mode=0750 -T <(cat << 'EOF'
[Unit]
Description=Update Flatpak

[Timer]
OnBootSec=2m
OnActiveSec=2m
OnUnitInactiveSec=24h
OnUnitActiveSec=24h
AccuracySec=1h
RandomizedDelaySec=10m

[Install]
WantedBy=timers.target
EOF) /etc/systemd/user/flatpak-update.timer


~~DISCUSSION~~

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies
pages/howtos/tmux/runnig_updates_in_tmux.txt · Last modified: 2022/06/19 17:07 by Heiko Mischer