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
|
|
|
|
# | + Stats32 |
|
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-20 19:47:35 +02:00
|
|
|
|
# Copyright 2017 Erreur32
|
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"
|
|
|
|
|
|
|
|
|
|
Installation of MOTDs32 | + Stats32 |
|
|
|
|
|
|
|
|
|
|
,--. ,--. ,-----. ,--------.,------. ,----. ,---.
|
|
|
|
|
| `.' |' .-. ''--. .--'| .-. \ ,---. '.-. |'.-. \
|
|
|
|
|
| |'.'| || | | | | | | | \ :( .-' .' ; .-' .'
|
|
|
|
|
| | | |' '-' ' | | | '--' /.-' `)/'-' |/ '-.
|
|
|
|
|
`--' `--' `-----' `--' `-------' `----' `----' '-----'
|
|
|
|
|
|
|
|
|
|
By Erreur32
|
|
|
|
|
|
|
|
|
|
# MOTDstat is dynamicaly refreshing the /etc/motd file with current informations
|
2017-07-20 19:47:35 +02:00
|
|
|
|
# about system status and usage.
|
2017-07-20 18:01:53 +02:00
|
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
|
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-20 16:37:26 +02:00
|
|
|
|
echo -e "\n\e[34mInstallation of MOTDs32 in progress... \e[0m"
|
2017-07-20 15:21:36 +02:00
|
|
|
|
|
2017-07-20 15:01:54 +02:00
|
|
|
|
## Install command in bashrc
|
2017-07-20 19:47:35 +02:00
|
|
|
|
echo "cat /etc/motd" >> /root/.bashrc
|
2017-07-20 15:01:54 +02:00
|
|
|
|
|
|
|
|
|
## Insdtall modules
|
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-20 15:43:36 +02:00
|
|
|
|
echo -e " -->\e[34m Stats32 already installed\e[0m"
|
2017-07-20 15:01:54 +02:00
|
|
|
|
else
|
|
|
|
|
mkdir /etc/motds32;
|
|
|
|
|
cp Stats32 /etc/motds32/Stats32 -Rf
|
2017-07-20 19:47:35 +02:00
|
|
|
|
|
2017-07-20 15:01:54 +02:00
|
|
|
|
fi
|
|
|
|
|
|
2017-07-20 15:32:43 +02:00
|
|
|
|
if [ -f /usr/bin/motd ]
|
2017-07-20 15:01:54 +02:00
|
|
|
|
then
|
2017-07-20 15:43:36 +02:00
|
|
|
|
echo -e " -->\e[34m motd already installed\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-20 22:32:57 +02:00
|
|
|
|
echo -e " -->\e[34m Copy files OK\n"
|
|
|
|
|
echo -e "\nDo you wish to install the required package?\n \e[0m --> apt-get install ntp figlet ? (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-20 22:34:19 +02:00
|
|
|
|
echo -e "\n\e[34m1.\e[92m apt-get install \e[0m ntp figlet \e[94m start\e[0m\n" ; apt-get install -y ntp figlet;
|
2017-07-20 22:08:20 +02:00
|
|
|
|
echo -e "\n\e[92mapt-get installation\e[0m Succesfull"
|
2017-07-20 22:32:18 +02:00
|
|
|
|
if [ -f /usr/bin/motds32 ]
|
|
|
|
|
then
|
|
|
|
|
echo -e "\nMake file done.\n"
|
|
|
|
|
else
|
|
|
|
|
make install
|
2017-07-20 22:35:03 +02:00
|
|
|
|
echo -e "\nMake file done.\n"
|
2017-07-20 22:32:18 +02:00
|
|
|
|
fi
|
2017-07-20 19:07:54 +02:00
|
|
|
|
else
|
2017-07-20 19:47:35 +02:00
|
|
|
|
echo -e "\nDo 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-20 22:32:18 +02:00
|
|
|
|
echo -e "\n\e[34m1.\e[92m No apt-get required\e[0m Installation continue... \n"; make install
|
2017-07-20 22:35:03 +02:00
|
|
|
|
else
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
2017-07-20 18:33:14 +02:00
|
|
|
|
fi
|
2017-07-20 14:20:10 +02:00
|
|
|
|
|
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-20 22:32:18 +02:00
|
|
|
|
echo -e "\e[34m2.\e[92m Cron already added."
|
2017-07-20 21:58:29 +02:00
|
|
|
|
else
|
2017-07-20 22:32:18 +02:00
|
|
|
|
echo -e "\e[34m2.\e[92m Cron added."
|
2017-07-20 22:08:20 +02:00
|
|
|
|
(crontab -l ; echo "*/5 * * * * root /usr/bin/motds32 -g 2>1")| crontab -
|
2017-07-20 21:58:29 +02:00
|
|
|
|
fi
|
2017-07-20 19:10:30 +02:00
|
|
|
|
|
2017-07-20 21:58:29 +02:00
|
|
|
|
#crontab -l | grep -q '/usr/bin/motds32' && echo 'entry exists' || echo -e "2.\e[92m Cron add ==> \e[0m */5 * * * * /usr/bin/motds32 -g 2>1 \e[92m (generate each 5 minutes)\n" && */5 * * * * root /usr/bin/motds32 -g 2>1
|
|
|
|
|
#crontab << FIN
|
|
|
|
|
#$(crontab -l)
|
|
|
|
|
#
|
|
|
|
|
#*/5 * * * * /usr/bin/motds32 -g 2>1
|
|
|
|
|
#FIN
|
2017-07-20 21:48:23 +02:00
|
|
|
|
## todo
|
|
|
|
|
### MOTDs32 generation (5 min)
|
|
|
|
|
#/5 * * * * /usr/bin/motds32 -g 2>1
|
|
|
|
|
###
|
|
|
|
|
|
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-20 22:38:04 +02:00
|
|
|
|
|
2017-07-20 22:38:46 +02:00
|
|
|
|
echo -e "\n\e[34m \e[92m Installation of MOTDs32 completed!\e[0m \n\nUse: /usr/bin/motds32 for help\n"
|
2017-07-20 15:21:36 +02:00
|
|
|
|
|
2017-07-20 19:21:52 +02:00
|
|
|
|
exit 0
|
2017-07-20 19:47:35 +02:00
|
|
|
|
#EOF
|