Skip to content

Commit

Permalink
Launch commands with 'screen' in case the session closes abruptly.
Browse files Browse the repository at this point in the history
  • Loading branch information
cybiohub committed Dec 13, 2022
1 parent e4e815b commit 4ce1891
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions bin/majserver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ readonly APTLOG='/var/log/maj-update.log'
# ## Force use of IPv4. To disable this option empty the variable.
readonly FORCEIPV4='-o Acquire::ForceIPv4=true'

# ## Enable protection for update/upgrade using screen if SSH connection is lost.
readonly screenProtect=1


#############################################################################################
# ## VARIABLES
Expand Down Expand Up @@ -93,22 +96,38 @@ function aptUpdate() {
function aptUpgrade() {
reminderCheck
#apt-get upgrade "${FORCEIPV4}"
screen -S "majserver" bash -c "apt-get upgrade ${FORCEIPV4}; echo -e '\n\e[38;5;208mPress enter to exit screen mode\e[0m\n\n'; read -r ANSWER"

if [ "${screenProtect}" -eq 1 ]; then
screen -S "majserver" bash -c "apt-get upgrade ${FORCEIPV4}; echo -e '\n\e[38;5;208mPress enter to exit screen mode\e[0m\n\n'; read -r ANSWER"
else
apt-get upgrade "${FORCEIPV4}"
fi


echo "${aptDate} - UpGrade System" >> "${APTLOG}"
}

# ## Launch dist-upgrade.
function aptDistUpgrade() {
reminderCheck
#apt-get dist-upgrade "${FORCEIPV4}"
screen -S "majserver" bash -c "apt-get dist-upgrade ${FORCEIPV4}; echo -e '\n\e[38;5;208mPress enter to exit screen mode\e[0m\n\n'; read -r ANSWER"
if [ "${screenProtect}" -eq 1 ]; then
screen -S "majserver" bash -c "apt-get dist-upgrade ${FORCEIPV4}; echo -e '\n\e[38;5;208mPress enter to exit screen mode\e[0m\n\n'; read -r ANSWER"
else
apt-get dist-upgrade "${FORCEIPV4}"
fi

echo "${aptDate} - Distribution UpGrade" >> "${APTLOG}"
}

# ## Launch do-release-upgrade.
function aptDoReleaseUpgrade() {
reminderCheck
screen -S "majserver" bash -c "apt-get do-release-upgrade ${FORCEIPV4}; echo -e '\n\e[38;5;208mPress enter to exit screen mode\e[0m\n\n'; read -r ANSWER"
if [ "${screenProtect}" -eq 1 ]; then
screen -S "majserver" bash -c "apt-get do-release-upgrade ${FORCEIPV4}; echo -e '\n\e[38;5;208mPress enter to exit screen mode\e[0m\n\n'; read -r ANSWER"
else
echo -e '\n\e[38;5;208mWARNING\e[0m Be sure to use screen, tmux or be local to run this command.\n\n'
fi
echo "${aptDate} - Do Release Upgrade" >> "${APTLOG}"
}

Expand Down

0 comments on commit 4ce1891

Please sign in to comment.