#!/bin/bash #set -x # debug mode # This should work on a Debian based system, any of them # Requires makeself and apt # Some menu things # colors # red = 1 # green = 2 # yellow = 3 # blue = 4 function cprint () { color="$1" shift echo "$(tput setaf $color)$*$(tput sgr0)" } function mprint (){ echo " $1 - $2" } function incorrect_selection() { cprint 1 "Incorrect selection! Try again." } function press_enter() { echo "" cprint 3 "Press Enter to continue " read clear } function copy_config() { cprint 2 "Creating restorable package..." sleep 1 tmpdir=$(mktemp -d) echo $tmpdir cp -r /etc/ $tmpdir dpkg --get-selections > $tmpdir/installed_packages arcdir=$(mktemp -d) echo $arcdir mkslf=$(which makeself.sh) echo $mkslf cp ./restore.bash $tmpdir $mkslf --gzip $tmpdir $arcdir/restore.run "SFX archive for restoration" ./restore.bash cp $arcdir/restore.run ./ cprint 2 "Done!" } function menu_option_two() { cprint 2 "Installing makeself..." sleep 1 wget https://github.com/megastep/makeself/releases/download/release-2.5.0/makeself-2.5.0.run chmod +x makeself-2.5.0.run ./makeself-2.5.0.run cd makeself-2.5.0 cp *.sh /usr/bin cprint 2 "Done!" } function cleanup() { cprint 2 "Cleaning up..." sleep 1 rm -rf $tmpdir rm -rf $arcdir } # Check for root only important on pure Debian as there is no sudo by default if [ "$(id -u)" != "0" ]; then # check is the system is debian if [ -f /etc/debian_version ]; then cprint 3 "Notice: This script may need to be run as root on Debian, especially if its a stock install. Also requires makeself to created a distributable self restorable package" ; press_enter ; fi fi until [ "$selection" = "0" ]; do clear echo "" cprint 3 " Main Menu" mprint 1 "Create a self restorable package" mprint 2 "Install makeself(required) to create self restorable package" mprint 0 "Exit" echo "" echo -n " Enter selection: " read selection echo "" case $selection in 1 ) clear ; copy_config ; press_enter ;; 2 ) clear ; menu_option_two ; press_enter ;; 0 ) clear ; cleanup ; exit ;; * ) clear ; incorrect_selection ; press_enter ;; esac done