save point
This commit is contained in:
parent
e3359be459
commit
6b681df935
4 changed files with 130 additions and 96 deletions
105
check.bash
105
check.bash
|
@ -1,101 +1,14 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#set -x # debug mode
|
# The componet to check system related things
|
||||||
|
|
||||||
# This should work on a Debian based system, any of them
|
if [ -f /usr/bin/makeself.sh ]; then
|
||||||
# Requires makeself and apt
|
# makeself is installed
|
||||||
|
echo "makeself is installed, good"
|
||||||
|
|
||||||
# Some menu things
|
else
|
||||||
|
|
||||||
# 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
|
|
||||||
|
|
||||||
|
# makeself is not installed
|
||||||
|
echo "makeself is not installed please install via this application"
|
||||||
|
sleep 3
|
||||||
|
fi
|
23
os_probe.bash
Executable file
23
os_probe.bash
Executable file
|
@ -0,0 +1,23 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# OS probing component
|
||||||
|
|
||||||
|
# Not an easy task to identify the distro, this app supports Debian based and Arch based
|
||||||
|
# Our best bet is to look for which package manager is installed
|
||||||
|
|
||||||
|
# check if apt-get is installed
|
||||||
|
|
||||||
|
if [ -x "$(command -v apt-get)" ]; then
|
||||||
|
# set environment variable for os
|
||||||
|
export osp="Debian"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# check if pacman is installed
|
||||||
|
|
||||||
|
if [ -x "$(command -v pacman)" ]; then
|
||||||
|
export osp="Arch"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# I know its so high tech and amazing right?
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@ function restore_config() {
|
||||||
apt install -y $(cat $aptpkgfile | awk '{print $1}')
|
apt install -y $(cat $aptpkgfile | awk '{print $1}')
|
||||||
# we should be set app wise now the configs
|
# we should be set app wise now the configs
|
||||||
cp -R etc/ /etc
|
cp -R etc/ /etc
|
||||||
|
cprint 3 "You may want to reboot for changes to take effect"
|
||||||
cprint 2 "Done!"
|
cprint 2 "Done!"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
97
syssetup.bash
Executable file
97
syssetup.bash
Executable file
|
@ -0,0 +1,97 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if [ "$(id -u)" != "0" ]; then
|
||||||
|
echo "You should run this script as root"
|
||||||
|
sleep 3
|
||||||
|
# exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check the OS, it sets a env variable as a result
|
||||||
|
./os_probe.bash
|
||||||
|
./check.bash
|
||||||
|
|
||||||
|
# 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
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
Loading…
Add table
Add a link
Reference in a new issue