Update install-old.sh
This commit is contained in:
parent
9705546bd0
commit
8d6fd00c49
1 changed files with 183 additions and 123 deletions
280
install-old.sh
280
install-old.sh
|
@ -33,11 +33,25 @@
|
|||
# ./install.sh
|
||||
#
|
||||
################################################################################
|
||||
# Make sure only root can run our script
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
echo "This script must be run as root" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
## clean terminal
|
||||
clear;
|
||||
|
||||
cat <<"EOF"
|
||||
#clear;
|
||||
BG_BLUE="$(tput setab 4)"
|
||||
BG_BLACK="$(tput setab 0)"
|
||||
FG_GREEN="$(tput setaf 2)"
|
||||
FG_WHITE="$(tput setaf 7)"
|
||||
# Save screen
|
||||
tput smcup
|
||||
# Display menu until selection == 0
|
||||
while [[ $REPLY != 0 ]]; do
|
||||
echo -n ${BG_BLACK}${FG_WHITE}
|
||||
clear
|
||||
cat <<- "EOFMO"
|
||||
|
||||
Installation of MOTDs32 | + Stats32 |
|
||||
|
||||
|
@ -49,70 +63,46 @@ cat <<"EOF"
|
|||
|
||||
By Erreur32
|
||||
|
||||
EOF
|
||||
|
||||
echo -e "\033[1;30m# MOTDs32 is dynamicaly refreshing the /etc/motd file with current informations"
|
||||
echo -e "\033[1;30m# about system status and usage."
|
||||
|
||||
|
||||
|
||||
# Make sure only root can run our script
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
echo "This script must be run as root" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo -e "\n\e[34mInstallation of MOTDs32 in progress... \e[0m\n\n"
|
||||
|
||||
## Install command in bashrc
|
||||
|
||||
#echo -ne '\e[0m # (5%)\r'
|
||||
#sleep 1
|
||||
#echo -e "\n\n"
|
||||
|
||||
if [ `grep -c /etc/motd /root/.bashrc` == 0 ]
|
||||
then
|
||||
echo -e " code bash missing"
|
||||
echo "cat /etc/motd" >> /root/.bashrc
|
||||
echo -e "\e[92m - Code bash \e[0madded.\n"
|
||||
else
|
||||
grepmot=`grep '/etc/motd' /root/.bashrc`
|
||||
echo -e " \e[1;30m Code bash found: \e[0m>>\e[0m $grepmot \e[0m<<\n"
|
||||
echo -e " -->\e[34m Code bash: \e[92mOK\e[0m"
|
||||
#sed -i '/cat \/etc\/motd/d' /root/.bashrc
|
||||
#echo -e "\e[92m Code .bashrc remove.\e[0m"
|
||||
fi
|
||||
|
||||
## Insdtall modules
|
||||
|
||||
|
||||
# Check if MOTDs32 is already add
|
||||
if [ -f "/etc/motds32/Stats32" ]
|
||||
then
|
||||
echo -e " -->\e[34m Stats32 \e[92mFOUND\e[0m"
|
||||
else
|
||||
mkdir /etc/motds32;
|
||||
cp Stats32 /etc/motds32/Stats32 -Rf
|
||||
echo -e " -->\e[34m Stats32 \e[92mINSTALLED\e[0m"
|
||||
fi
|
||||
EOFMO
|
||||
echo -e "\033[1;30m # MOTDs32 is dynamicaly refreshing the /etc/motd file with current informations"
|
||||
echo -e "\033[1;30m # about system status and usage."
|
||||
echo -e "\n \e[34m Installation of MOTDs32 in progress... \e[0m\n\n"
|
||||
|
||||
# Check files
|
||||
echo -e " -->\e[34m Check files:\n"
|
||||
#echo -ne '\e[0m #########(50%)\r'
|
||||
#sleep 1
|
||||
#echo -ne "\n"
|
||||
command -v figlet >/dev/null 2>&1 || { echo >&2 "Figlet is not installed."; }
|
||||
command -v ntpd >/dev/null 2>&1 || { echo >&2 "ntp is not installed."; }
|
||||
command -v make >/dev/null 2>&1 || { echo >&2 "build-essential is not installed."; }
|
||||
echo -e "\n\e[92m"
|
||||
echo -e "\nDo you wish to install the required package?\n \e[0m --> apt-get install ntp figlet build-essential ? (y/n) "
|
||||
old_stty_cfg=$(stty -g)
|
||||
stty raw -echo
|
||||
answer=$( while ! head -c 1 | grep -i '[ny]' ;do true ;done )
|
||||
stty $old_stty_cfg
|
||||
if echo "$answer" | grep -iq "^y" ;then
|
||||
echo -e "\n\e[34m - apt-get install ntp figlet build-essential \e[0m>>\e[92m starting\e[0m\n" ; apt-get install -y build-essential ntp figlet;
|
||||
echo -e "\n\e[34m - apt-get installation \e[0m>> Succesfull\n"
|
||||
#echo -e " -->\e[34m Check files:"
|
||||
if hash figlet 2>/dev/null; then
|
||||
echo -e " \e[34m- Figlet \e[32minstalled.\e[0m"
|
||||
else
|
||||
echo -e " \e[34m- Figlet \e[1;31mis not installed.\e[0m"
|
||||
fi
|
||||
if hash ntpd 2>/dev/null; then
|
||||
echo -e " \e[34m- NTP \e[32minstalled.\e[0m"
|
||||
else
|
||||
echo -e " \e[34m- NTP \e[1;31mis not installed.\e[0m"
|
||||
fi
|
||||
if hash make 2>/dev/null; then
|
||||
echo -e " \e[34m- build-essential \e[32minstalled.\e[0m"
|
||||
else
|
||||
echo -e " \e[34m- build-essential \e[1;31mis not installed.\e[0m"
|
||||
fi
|
||||
echo -e "\n YOU CAN SKIP auto install if you want"
|
||||
echo -e "\n\e[92m Please Select:"
|
||||
echo -e " 1. \e[0m(auto)Install Missing Package\e[92m"
|
||||
echo -e " 2. \e[0mContinue installation script\e[92m"
|
||||
echo -e " 0. \e[0mQuit\n \e[0m"
|
||||
read -p " Enter selection [0-2] > " selection
|
||||
|
||||
# Clear area beneath menu
|
||||
tput cup 10 0
|
||||
echo -n ${BG_BLACK}${FG_GREEN}
|
||||
tput ed
|
||||
tput cup 11 0
|
||||
|
||||
# Act on selection
|
||||
case $selection in
|
||||
1) echo -e " \e[32m install missing package ...\e[0m\n"
|
||||
apt-get install -y build-essential ntp figlet
|
||||
echo -e "\n\e[34m - apt-get installation build-essential ntp figlet \e[0m>> Succesfull"
|
||||
if [ -f "/usr/bin/motds32" ]
|
||||
then
|
||||
echo -e "\n\e[34m - Make file \e[0m>> already done.\e[0m\n"
|
||||
|
@ -121,69 +111,139 @@ if echo "$answer" | grep -iq "^y" ;then
|
|||
make install
|
||||
echo -e "\n\e[34m - Make file done.\e[0m\n"
|
||||
fi
|
||||
else
|
||||
echo -e "\n\e[34mDo you want to continue this installation? (y/n)\n "
|
||||
old2_stty_cfg=$(stty -g)
|
||||
stty raw -echo
|
||||
answer2=$( while ! head -c 2 | grep -i '[ny]' ;do true ;done )
|
||||
stty $old2_stty_cfg
|
||||
if echo "$answer2" | grep -iq "^y" ;then
|
||||
echo -e "\n\e[34m - NO apt-get required\e[0m Installation continue... \n";
|
||||
if [ -f "/usr/bin/motds32" ]
|
||||
then
|
||||
echo -e "\n\e[34m - Make file \e[0m>> Succesfull\n"
|
||||
else
|
||||
echo -e "\n\e[94m -Building binary \e[0m\n"
|
||||
make install
|
||||
echo -e "\n\e[34m - Make file done.\e[0m\n"
|
||||
fi
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
#command -v figlet >/dev/null 2>&1 || { echo >&2 "Figlet is not installed."; echo "need to install figlet /y"; }
|
||||
if [ -f "/usr/share/figlet" ]
|
||||
echo -e "\e[92m"
|
||||
if [ `grep -c /etc/motd /root/.bashrc` == 0 ]
|
||||
then
|
||||
echo -e " \e[1;31m code bash missing"
|
||||
echo "cat /etc/motd" >> /root/.bashrc
|
||||
echo -e "\e[92m - Code bash \e[0madded.\n"
|
||||
else
|
||||
grepmot=`grep '/etc/motd' /root/.bashrc`
|
||||
echo -e " \e[1;30m Code bash found: \e[0m>>\e[0m $grepmot \e[0m<<\n"
|
||||
echo -e " -->\e[34m Code bash: \e[92mOK\e[0m"
|
||||
#sed -i '/cat \/etc\/motd/d' /root/.bashrc
|
||||
#echo -e "\e[92m Code .bashrc remove.\e[0m"
|
||||
fi
|
||||
|
||||
# Check if MOTDs32 is already add
|
||||
if [ -f "/etc/motds32/Stats32" ]
|
||||
then
|
||||
echo -e " -->\e[34m Stats32 \e[92mFOUND\e[0m"
|
||||
else
|
||||
mkdir /etc/motds32;
|
||||
cp Stats32 /etc/motds32/Stats32 -Rf
|
||||
echo -e " -->\e[34m Stats32 \e[92mINSTALLED\e[0m"
|
||||
fi
|
||||
|
||||
# Copy font figlet
|
||||
if [ -f "/usr/share/figlet" ]
|
||||
then
|
||||
echo -e " -->\e[31m figlet not FOUND\e[0m"
|
||||
else
|
||||
cp -Rf fonts/chunky.flf /usr/share/figlet/
|
||||
echo -e " -->\e[34m Font figlet \e[92mOK\e[0m"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check motd
|
||||
if [ -f "/usr/bin/motd" ]
|
||||
# Check if motd is installed correctly
|
||||
if [ -f "/usr/bin/motd" ]
|
||||
then
|
||||
echo -e " -->\e[34m motd check \e[92mOK\e[0m\n"
|
||||
else
|
||||
ln -s /usr/bin/motds32 /usr/bin/motd
|
||||
echo -e " -->\e[34m motd bin \e[92mOK\e[0m\n"
|
||||
fi
|
||||
fi
|
||||
## Install Crontab
|
||||
if crontab -l | grep -q '/usr/bin/motds32'; then
|
||||
echo -e "\e[34m - Cron \e[0m>> already added.\e[0m"
|
||||
else
|
||||
echo -e "\e[34m - Cron added.\e[0m"
|
||||
(crontab -l ; echo "*/5 * * * * /usr/bin/motds32 -g 2>1")| crontab -
|
||||
fi
|
||||
## Generate first stats
|
||||
/usr/bin/motds32 -g
|
||||
|
||||
echo -e "\n\n\e[34m \e[92m Installation of MOTDs32 completed!\e[0m \n\n\n Help? Use: \n \033[1;30m /usr/bin/motds32\e[0m \n or \033[1;30m\n motd\e[0m\n"
|
||||
printf "\n \e[1;33m (Press any key to exit.)\e[0m"
|
||||
read -n 1
|
||||
echo "Installation MOTDs32 terminated."
|
||||
exit 1
|
||||
# Restore screen
|
||||
tput rmcup
|
||||
;;
|
||||
2) echo -e "\n\e[92m"
|
||||
if [ `grep -c /etc/motd /root/.bashrc` == 0 ]
|
||||
then
|
||||
echo -e " code bash missing"
|
||||
echo "cat /etc/motd" >> /root/.bashrc
|
||||
echo -e "\e[92m - Code bash \e[0madded.\n"
|
||||
else
|
||||
grepmot=`grep '/etc/motd' /root/.bashrc`
|
||||
echo -e " \e[1;30m Code bash found: \e[0m>>\e[0m $grepmot \e[0m<<\n"
|
||||
echo -e " -->\e[34m Code bash: \e[92mOK\e[0m"
|
||||
#sed -i '/cat \/etc\/motd/d' /root/.bashrc
|
||||
#echo -e "\e[92m Code .bashrc remove.\e[0m"
|
||||
fi
|
||||
|
||||
#echo -ne '\e[0m ##################(90%)\r'
|
||||
#sleep 1
|
||||
#echo -e "\n"
|
||||
# Check if MOTDs32 is already add
|
||||
if [ -f "/etc/motds32/Stats32" ]
|
||||
then
|
||||
echo -e " -->\e[34m Stats32 \e[92mFOUND\e[0m"
|
||||
else
|
||||
mkdir /etc/motds32;
|
||||
cp Stats32 /etc/motds32/Stats32 -Rf
|
||||
echo -e " -->\e[34m Stats32 \e[92mINSTALLED\e[0m"
|
||||
fi
|
||||
|
||||
# Copy font figlet
|
||||
if [ -f "/usr/share/figlet" ]
|
||||
then
|
||||
echo -e " -->\e[31m figlet not FOUND\e[0m"
|
||||
else
|
||||
cp -Rf fonts/chunky.flf /usr/share/figlet/
|
||||
echo -e " -->\e[34m Font figlet \e[92mOK\e[0m"
|
||||
fi
|
||||
|
||||
## Install Crontab
|
||||
|
||||
if crontab -l | grep -q '/usr/bin/motds32'; then
|
||||
echo -e "\e[34m - Cron \e[0m>> already added.\e[0m"
|
||||
else
|
||||
echo -e "\e[34m - Cron added.\e[0m"
|
||||
(crontab -l ; echo "*/5 * * * * /usr/bin/motds32 -g 2>1")| crontab -
|
||||
fi
|
||||
|
||||
# Check if motd ins talled correctly
|
||||
if [ -f "/usr/bin/motd" ]
|
||||
then
|
||||
echo -e " -->\e[34m motd check \e[92mOK\e[0m\n"
|
||||
else
|
||||
ln -s /usr/bin/motds32 /usr/bin/motd
|
||||
echo -e " -->\e[34m motd bin \e[92mOK\e[0m\n"
|
||||
fi
|
||||
|
||||
## Install Crontab
|
||||
if crontab -l | grep -q '/usr/bin/motds32'; then
|
||||
echo -e "\e[34m - Cron \e[0m>> already added.\e[0m"
|
||||
else
|
||||
echo -e "\e[34m - Cron added.\e[0m"
|
||||
(crontab -l ; echo "*/5 * * * * /usr/bin/motds32 -g 2>1")| crontab -
|
||||
fi
|
||||
## Generate first stats
|
||||
/usr/bin/motds32 -g
|
||||
echo -e "\n\n\e[34m \e[92m Installation of MOTDs32 completed!\e[0m \n\n\n Help? Use: \n \033[1;30m /usr/bin/motds32\e[0m \n or \033[1;30m\n motd\e[0m\n"
|
||||
printf "\n \e[1;33m (Press any key to exit.)\e[0m"
|
||||
read -n 1
|
||||
echo "Installation MOTDs32 terminated."
|
||||
exit 1
|
||||
# Restore screen
|
||||
tput rmcup
|
||||
;;
|
||||
0) break
|
||||
;;
|
||||
*) break
|
||||
;;
|
||||
esac
|
||||
|
||||
## Generate first stats
|
||||
/usr/bin/motds32 -g
|
||||
/usr/bin/motds32 -g
|
||||
|
||||
#echo -ne '\n\e[0m #######################(100%)\r\n\n'
|
||||
echo -e "\n\n\e[34m \e[92m Installation of MOTDs32 completed!\n\n"
|
||||
echo -e "----------------------------------------------------------\e[0m"
|
||||
echo -e "\n Help? Use: \n \033[1;30m /usr/bin/motds32\e[0m \n or \033[1;30m\n motd\e[0m\n"
|
||||
echo -e "\n\n\e[34m \e[92m Installation of MOTDs32 completed!\e[0m \n\n\n Help? Use: \n \033[1;30m /usr/bin/motds32\e[0m \n or \033[1;30m\n motd\e[0m\n"
|
||||
printf "\n \e[1;33m (Press any key to exit.)\e[0m"
|
||||
read -n 1
|
||||
done
|
||||
|
||||
exit 0
|
||||
#EOF
|
||||
# Restore screen
|
||||
tput rmcup
|
||||
echo "Installation MOTDs32 terminated."
|
||||
|
|
Loading…
Reference in a new issue