MOTDs32/install.sh

175 lines
5.0 KiB
Bash
Raw Normal View History

2017-07-20 15:01:54 +02:00
#!/bin/sh
2017-07-18 23:06:11 +02:00
#
2017-07-20 15:01:54 +02:00
# MOTDs32 installation instructions
# ==================================
#
# (2017) New project MOTDs32 by Erreur32
2017-07-18 23:06:11 +02:00
# Author: Erreur32
# Version 0.0.5
#
2017-07-20 15:01:54 +02:00
# https://gitlab.echosystem.fr/Erreur32/MOTDs32
#
# ,--. ,--. ,-----. ,--------.,------. ,----. ,---.
# | `.' |' .-. ''--. .--'| .-. \ ,---. '.-. |'.-. \
# | |'.'| || | | | | | | | \ :( .-' .' < .-' .'
# | | | |' '-' ' | | | '--' /.-' `)/'-' |/ '-.
# `--' `--' `-----' `--' `-------' `----' `----' '-----'
#
2017-07-20 19:47:35 +02:00
# | + |
2017-07-18 23:06:11 +02:00
# MOTDstat is dynamicaly refreshing the /etc/motd file with current informations
# about system status and usage.
#
2017-07-26 10:20:15 +02:00
# Copyright 2017 🅴🆁🆁🅴🆄🆁32
2017-07-18 23:06:11 +02:00
# original project: Pavol Krigler <pavol.krigler@gelogic.net>
#
2017-07-20 16:02:57 +02:00
# make sur this file is executable +x
2017-07-20 15:01:54 +02:00
################################################################################
#
2017-07-20 19:47:35 +02:00
# Installation
2017-07-20 15:01:54 +02:00
# ============
#
# As root execute this command (the easy way!):
#
2017-07-20 20:50:22 +02:00
# ./install.sh
2017-07-20 19:47:35 +02:00
#
################################################################################
## clean terminal
2017-07-19 09:22:15 +02:00
clear;
2017-07-20 18:01:53 +02:00
cat <<"EOF"
2017-07-21 10:43:16 +02:00
| + |
2017-07-20 18:01:53 +02:00
2017-07-21 10:43:16 +02:00
,--. ,--. ,-----. ,--------.,------. ,----. ,---.
| `.' |' .-. ''--. .--'| .-. \ ,---. '.-. |'.-. \
| |'.'| || | | | | | | | \ :( .-' .' ; .-' .'
| | | |' '-' ' | | | '--' /.-' `)/'-' |/ '-.
`--' `--' `-----' `--' `-------' `----' `----' '-----'
2017-07-20 18:01:53 +02:00
By
EOF
2017-07-21 10:43:16 +02:00
echo -e "\033[1;30m# MOTDstat is dynamicaly refreshing the /etc/motd file with current informations"
echo -e "\033[1;30m# about system status and usage."
2017-07-20 18:23:52 +02:00
# 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
2017-07-20 18:01:53 +02:00
2017-07-21 09:25:02 +02:00
echo -e "\n\e[34mInstallation of in progress... \e[0m\n\n"
2017-07-20 15:21:36 +02:00
2017-07-20 15:01:54 +02:00
## Install command in bashrc
2017-07-21 01:13:06 +02:00
2017-07-21 09:25:02 +02:00
#echo -ne '\e[0m # (5%)\r'
#sleep 1
#echo -e "\n\n"
2017-07-21 01:09:00 +02:00
if [ `grep -c /etc/motd /root/.bashrc` == 0 ]
then
2017-07-21 13:02:35 +02:00
echo -e " code bash missing"
2017-07-20 19:47:35 +02:00
echo "cat /etc/motd" >> /root/.bashrc
2017-07-25 20:43:04 +02:00
echo -e "\e[92m - Code bash \e[0madded.\n"
2017-07-21 01:09:00 +02:00
else
2017-07-21 13:02:35 +02:00
grepmot=`grep '/etc/motd' /root/.bashrc`
2017-07-25 21:35:09 +02:00
echo -e " \e[1;30m Code bash found: \e[0m>>\e[0m $grepmot \e[0m<<\n"
2017-07-25 20:57:36 +02:00
echo -e " -->\e[34m Code bash: \e[92mOK\e[0m"
2017-07-21 01:09:00 +02:00
#sed -i '/cat \/etc\/motd/d' /root/.bashrc
#echo -e "\e[92m Code .bashrc remove.\e[0m"
fi
2017-07-21 01:27:58 +02:00
2017-07-20 15:01:54 +02:00
## Insdtall modules
2017-07-25 19:28:18 +02:00
if [ -f "/usr/share/figlet/" ]
then
echo -e " -->\e[34m Copy font figlet\e[0m"
2017-07-25 20:43:04 +02:00
cp -f fonts/chunky.flf /usr/share/figlet/
2017-07-25 19:28:18 +02:00
fi
2017-07-20 19:47:35 +02:00
2017-07-20 15:32:43 +02:00
if [ -f "/etc/motds32/Stats32" ]
2017-07-20 15:01:54 +02:00
then
2017-07-25 20:45:57 +02:00
echo -e " -->\e[34m Stats32 already \e[92minstalled\e[0m"
2017-07-20 15:01:54 +02:00
else
mkdir /etc/motds32;
cp Stats32 /etc/motds32/Stats32 -Rf
2017-07-25 19:28:18 +02:00
2017-07-20 15:01:54 +02:00
fi
2017-07-21 01:19:30 +02:00
2017-07-25 20:50:06 +02:00
if [ -f "/usr/bin/motd" ]
2017-07-20 15:01:54 +02:00
then
2017-07-25 20:45:57 +02:00
echo -e " -->\e[34m motd already \e[92minstalled\e[0m"
2017-07-20 15:01:54 +02:00
else
ln -s /usr/bin/motds32 /usr/bin/motd
2017-07-20 19:47:35 +02:00
2017-07-20 15:01:54 +02:00
fi
2017-07-21 01:13:06 +02:00
2017-07-25 20:45:57 +02:00
echo -e " -->\e[34m Check files: \e[92mOK\n"
2017-07-21 09:25:02 +02:00
#echo -ne '\e[0m #########(50%)\r'
#sleep 1
#echo -ne "\n"
2017-07-25 19:28:18 +02:00
echo -e "\nDo you wish to install the required package?\n \e[0m --> apt-get install ntp figlet build-essential ? (y/n) "
2017-07-18 23:06:11 +02:00
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
2017-07-25 21:37:22 +02:00
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;
2017-07-25 21:36:50 +02:00
echo -e "\n\e[34m - apt-get installation \e[0m>> Succesfull\n"
2017-07-25 21:05:30 +02:00
if [ -f "/usr/bin/motds32" ]
2017-07-20 22:32:18 +02:00
then
2017-07-25 21:36:50 +02:00
echo -e "\n\e[34m - Make file \e[0m>> already done.\e[0m\n"
2017-07-20 22:32:18 +02:00
else
2017-07-25 20:43:04 +02:00
echo -e "\n\e[92m -Building binary \e[0m\n"
2017-07-20 22:32:18 +02:00
make install
2017-07-25 21:34:28 +02:00
echo -e "\n\e[34m - Make file done.\e[0m\n"
2017-07-20 22:32:18 +02:00
fi
2017-07-20 19:07:54 +02:00
else
2017-07-21 01:25:35 +02:00
echo -e "\n\e[34mDo you want to continue this installation? (y/n)\n "
2017-07-20 19:24:24 +02:00
old2_stty_cfg=$(stty -g)
2017-07-20 18:33:14 +02:00
stty raw -echo
2017-07-20 19:47:35 +02:00
answer2=$( while ! head -c 2 | grep -i '[ny]' ;do true ;done )
2017-07-20 19:24:24 +02:00
stty $old2_stty_cfg
if echo "$answer2" | grep -iq "^y" ;then
2017-07-25 21:22:36 +02:00
echo -e "\n\e[34m - NO apt-get required\e[0m Installation continue... \n";
2017-07-25 21:05:30 +02:00
if [ -f "/usr/bin/motds32" ]
2017-07-25 21:01:29 +02:00
then
2017-07-25 21:36:50 +02:00
echo -e "\n\e[34m - Make file \e[0m>> Succesfull\n"
2017-07-25 21:01:29 +02:00
else
2017-07-25 21:22:36 +02:00
echo -e "\n\e[94m -Building binary \e[0m\n"
2017-07-25 21:01:29 +02:00
make install
2017-07-25 21:34:28 +02:00
echo -e "\n\e[34m - Make file done.\e[0m\n"
2017-07-25 21:01:29 +02:00
fi
2017-07-20 22:35:03 +02:00
else
exit 1
fi
2017-07-20 18:33:14 +02:00
fi
2017-07-21 01:16:57 +02:00
2017-07-21 09:25:02 +02:00
#echo -ne '\e[0m ##################(90%)\r'
#sleep 1
#echo -e "\n"
2017-07-18 23:06:11 +02:00
## Install Crontab
2017-07-20 21:58:29 +02:00
if crontab -l | grep -q '/usr/bin/motds32'; then
2017-07-25 21:34:28 +02:00
echo -e "\e[34m - Cron \e[0m>> already added.\e[0m"
2017-07-20 21:58:29 +02:00
else
2017-07-25 21:34:28 +02:00
echo -e "\e[34m - Cron added.\e[0m"
2017-07-21 09:03:10 +02:00
(crontab -l ; echo "*/5 * * * * /usr/bin/motds32 -g 2>1")| crontab -
2017-07-20 21:58:29 +02:00
fi
2017-07-21 01:09:00 +02:00
2017-07-21 09:25:02 +02:00
2017-07-20 19:47:35 +02:00
2017-07-20 11:00:56 +02:00
## Generate first stats
2017-07-18 23:06:11 +02:00
/usr/bin/motds32 -g
2017-07-21 01:16:57 +02:00
2017-07-21 09:25:02 +02:00
#echo -ne '\n\e[0m #######################(100%)\r\n\n'
2017-07-25 20:45:57 +02:00
echo -e "\n\n\e[34m \e[92m 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"
2017-07-21 01:09:00 +02:00
2017-07-20 19:21:52 +02:00
exit 0
2017-07-20 19:47:35 +02:00
#EOF