first commit
This commit is contained in:
parent
68ce9978ef
commit
929bf74b60
7 changed files with 341 additions and 88 deletions
|
@ -1,3 +1,9 @@
|
|||
2020-05-18
|
||||
- Add features with Stat32.
|
||||
- Fix install.sh
|
||||
- Add Update Script on install.sh
|
||||
- Optimisation.
|
||||
|
||||
2017-07-17
|
||||
--> motdstat 0.0.4 become MOTDs32 0.0.5
|
||||
- NEW features: add more info
|
||||
|
|
8
INSTALL
8
INSTALL
|
@ -4,7 +4,7 @@ MOTDs32 installation instructions
|
|||
(2017) New project MOTDs32 by 🅴🆁🆁🅴🆄🆁32
|
||||
|
||||
|
||||
https://gitlab.echosystem.fr/Erreur32/MOTDs32
|
||||
https://git.echosystem.fr/Erreur32/MOTDs32
|
||||
|
||||
,--. ,--. ,-----. ,--------.,------. ,----. ,---.
|
||||
| `.' |' .-. ''--. .--'| .-. \ ,---. '.-. |'.-. \
|
||||
|
@ -25,7 +25,7 @@ Installation
|
|||
|
||||
Clone the repo where you want and
|
||||
|
||||
git clone https://gitlab.echosystem.fr/Erreur32/MOTDs32.git
|
||||
git clone https://git.echosystem.fr/Erreur32/MOTDs32.git
|
||||
|
||||
Type in terminal as ROOT (in the MOTDs32 directory):
|
||||
|
||||
|
@ -45,8 +45,8 @@ Uninstall instructions
|
|||
|
||||
type in terminal (in the MOTDs32 directory):
|
||||
|
||||
./unisntall.sh
|
||||
./isntall.sh (option 4)
|
||||
|
||||
|
||||
|
||||
By 🅴🆁🆁🅴🆄🆁32
|
||||
By 🅴🆁🆁🅴🆄🆁32
|
||||
|
|
2
Makefile
2
Makefile
|
@ -27,5 +27,3 @@ uninstall:
|
|||
for prog in $(PROGRAMS); do \
|
||||
rm -f /usr/bin/$$prog; \
|
||||
done
|
||||
rm -rf /etc/motds32/ /etc/motd.full
|
||||
mv -f /etc/motd.orig /etc/motd
|
||||
|
|
3
Stats32
3
Stats32
|
@ -53,5 +53,6 @@ echo -e "\nConected Users $(users | wc -w) \e[3m $(date "+%D %T")\e[0;0m\e[3
|
|||
[[ -z "$users" ]] && last -a -n $users | grep pts | head -3 || last -a -n $users | grep pts | head -3
|
||||
echo -e "\e[0m"
|
||||
#[[ -z "$users" ]] && echo "Empty" || echo "Not empty"
|
||||
echo -e "\e[93m Generated by MOTDs32\e[0m"
|
||||
#echo -e "\e[93m Generated by MOTDs32\e[0m"
|
||||
echo -e "\e[93m Generated by Stats32\e[0m"
|
||||
#echo -n " Welcome " ; whoami
|
||||
|
|
23
bin/motds32
23
bin/motds32
|
@ -10,19 +10,19 @@
|
|||
# Copyright 2013 Pavol Krigler <pavol.krigler@gelogic.net>
|
||||
#
|
||||
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
echo " Need to be ROOT to executing this file" 1>&2
|
||||
else
|
||||
/bin/bash /etc/motds32/Stats32 > /etc/motds32/Stats32.txt
|
||||
# if [[ $EUID -ne 0 ]]; then
|
||||
# echo " Need to be ROOT to executing this file" 1>&2
|
||||
# else
|
||||
# /bin/bash /etc/motds32/Stats32 > /etc/motds32/Stats32.txt
|
||||
# echo -e "\n Generating Stats file" 1>&2
|
||||
fi
|
||||
# fi
|
||||
|
||||
# Path to the configuration file
|
||||
CONFIGFILE="/etc/motds32/motds32.conf"
|
||||
|
||||
# Message of the day file
|
||||
MOTD='/etc/motd'
|
||||
MOTD32="/etc/motds32/Stats32"
|
||||
#MOTD32="/etc/motds32/Stats32"
|
||||
PRG32="/etc/motds32"
|
||||
# List of network services which MUST be running
|
||||
NETSERVICE_LIST="/etc/motds32/netservice"
|
||||
|
@ -82,13 +82,6 @@ fi
|
|||
#
|
||||
# Generate stats data
|
||||
#
|
||||
## not use yet
|
||||
function stats_data() {
|
||||
#make stats file in the good directory
|
||||
$MOTD32 > $PRG32/Stats32.txt
|
||||
}
|
||||
#$stats_data
|
||||
#$MOTD32 > $PRG32/Stats32.txt
|
||||
|
||||
#
|
||||
# Append message to the report (and to syslog if enabled)
|
||||
|
@ -639,9 +632,9 @@ paste -d "" $COLL_DISK $COLL_EMPTY $COLL_MEM $COLL_EMPTY $COLL_PROC | head -n $M
|
|||
if [[ $EUID -ne 0 ]]; then
|
||||
echo "MOTD available only with root" 1>&2
|
||||
else
|
||||
cat /etc/motds32/Stats32.txt >> $MOTD
|
||||
#cat /etc/motds32/Stats32.txt >> $MOTD
|
||||
# /bin/bash /etc/motds32/Stats32 > /etc/motds32/Stats32.txt
|
||||
# echo -e "\n Generating Stats file" 1>&2
|
||||
echo -e "\n Generating Stats file" 1>&2
|
||||
fi
|
||||
|
||||
# Full report
|
||||
|
|
154
crontab.backup
Normal file
154
crontab.backup
Normal file
|
@ -0,0 +1,154 @@
|
|||
# crontab 2019
|
||||
|
||||
# >/dev/null -- aucun log
|
||||
# &>/dev/null -- aucun log
|
||||
# 2>&1 -- only error
|
||||
# >/dev/null 2>&1 -- only error
|
||||
|
||||
# output=$(command) # stdout only; stderr remains uncaptured
|
||||
# output=$(command 2>&1) # both stdout and stderr will be captured
|
||||
|
||||
#@weekly /sbin/iptables-save > /home/backup/iptables.echo.firewall
|
||||
#iptables -L INPUT -v --line-numbers
|
||||
### 666.echosystem.fr
|
||||
#8 6 * * * curl -fsS --retry 3 http://localhost:8037/ping/9df6cf0c-0146-4926-8e09-ec332d2ff825 > /dev/null
|
||||
### Freshrss
|
||||
#52 * * * * /usr/bin/goaccess /etc/goaccess.conf -a -o /home/www-adm1n/MonitorinG/Goaccess/goaccess-cron.html &>/dev/null
|
||||
### StatRRD ### https://adm1n.echosystem.fr/graph-statRRD.php
|
||||
### https://adm1n.echosystem.fr/graph-StatusServ32.php
|
||||
#*/2 * * * * su -s /bin/bash www-data -c "/bin/bash /home/www-adm1n/MonitorinG/StatusServ32/statRRD graph" >/dev/null
|
||||
### OK WORK https://adm1n.echosystem.fr/RRDTOOL/traffic.cgi
|
||||
#* * * * * echo "loadavg=`cat /proc/loadavg`" | curl -d @- https://adm1n.echosystem.fr/MonitorinG/statusboard-server-load/
|
||||
#update OLD https://adm1n.echosystem.fr/RRDTOOLHOME/StatsRRD.php
|
||||
#* * * * * rrdupdate /home/tools/StatRRD/rrd/trafic_eth0.rrd $(/bin/grep eth0 /proc/net/dev | cut -d: -f2 | awk -v ts=`date +\%s` '{print ts":"$1":"$9}') && rrdupdate /home/tools/StatRRD/rrd/temperature.rrd $(echo "$(/bin/cat /sys/class/thermal/thermal_zone0/temp)/1000" | bc |awk -v ts=`date +\%s` '{print ts":"$1}') && rrdupdate /home/tools/StatRRD/rrd/cpu.rrd $(uptime | cut -d: -f5 | tr ',' ' ' | awk -v ts=`date +\%s` '{print ts":"$1":"$2":"$3}') && rrdupdate /home/tools/StatRRD/rrd/memoire.rrd $(/bin/grep Mem /proc/meminfo | cut -d: -f2 | tr 'kB\n' ' ' | awk -v ts=`date +\%s` '{print ts":"$1":"$2}')
|
||||
#*/5 * * * * /bin/bash /home/tools/StatRRD/Old/rrdtool.cron.sh | 2>&1
|
||||
#############################################################################################
|
||||
# at 5 a.m every week with: # 0 5 * * 1 tar -zcf backups/home.tgz /home/ --> &>/dev/null
|
||||
|
||||
# ┌────────── minute (0 - 59)
|
||||
# │ ┌──────── hour (0 - 23)
|
||||
# │ │ ┌────── day of month (1 - 31)
|
||||
# │ │ │ ┌──── month (1 - 12)
|
||||
# │ │ │ │ ┌── day of week (0 - 6 => Sunday - Saturday, or 1 - 7 => Monday - Sunday)
|
||||
# │ │ │ │ │
|
||||
# ↓ ↓ ↓ ↓ ↓
|
||||
# * * * * * command to be executed
|
||||
# m h dom mon dow command
|
||||
|
||||
SHELL=/bin/bash
|
||||
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/home/composer/.composer/vendor/bin:/opt/node/bin:/usr/local/go:/usr/local/go/bin/bin:/home/tools/SH:/home/composer/Web_install/phpqa:/root/bin:/home/tools/GIT_stat/gitinspector
|
||||
|
||||
#PATH=$PATH:/home/tools/SH:/home/composer/Web_install/phpqa:/root/bin
|
||||
#PATH=$PATH:/home/tools/GIT_stat/gitinspector
|
||||
|
||||
@reboot sh /etc/init.d/AuReboot
|
||||
|
||||
### MonitorinG
|
||||
5 * * * * vnstati -s -i eth0 -o /home/www-adm1n/MonitorinG/vnstat/summary.png >/dev/null
|
||||
2 * * * * vnstati -h -i eth0 -o /home/www-adm1n/MonitorinG/vnstat/hourly.png >/dev/null
|
||||
2 * * * * vnstati -d -i eth0 -o /home/www-adm1n/MonitorinG/vnstat/daily.png >/dev/null
|
||||
2 * * * * vnstati -t -i eth0 -o /home/www-adm1n/MonitorinG/vnstat/top10.png >/dev/null
|
||||
2 * * * * vnstati -m -i eth0 -o /home/www-adm1n/MonitorinG/vnstat/monthly.png >/dev/null
|
||||
|
||||
### Stats GIT
|
||||
### #SHELL=/bin/bash #PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/home/tools/gitinspector
|
||||
# MOTDs32
|
||||
#2 */6 * * * cd /root/MOTDs32 ; git log --stat --no-merges --summary > /home/www/html/_page/GITSTAT/MOTDs32/log/repo_log
|
||||
2 * * * * sudo /usr/bin/python /home/tools/GIT_stat/gitinspector/gitinspector.py --format=htmlembedded --file-types=** -HlmrTw /root/MOTDs32/ > /home/www/html/_page/GITSTAT/MOTDs32/gitinspector/index.html >/dev/null 2>&1
|
||||
2 * * * * /usr/local/bin/gitstats /root/MOTDs32/ /home/www/html/_page/GITSTAT/MOTDs32/gitstats/ >/dev/null 2>&1
|
||||
2 * * * * /usr/local/bin/repostat --no-browser --copy-assets /root/MOTDs32/ /home/www/html/_page/GITSTAT/MOTDs32/repostat/ >/dev/null 2>&1
|
||||
2 * * * * sudo /usr/local/bin/git_stats generate --path=/root/MOTDs32/ --out-path=/home/www/html/_page/GITSTAT/MOTDs32/git_stats/ >/dev/null 2>&1
|
||||
# 2>&1
|
||||
# Bash3lper
|
||||
#2 */6 * * * cd /home/erreur32/Bash3lper ; git log --stat --no-merges --summary > /home/www/html/_page/GITSTAT/Bash3lper/log/repo_log
|
||||
2 * * * * sudo /usr/bin/python /home/tools/GIT_stat/gitinspector/gitinspector.py --format=htmlembedded --file-types=** -HlmrTw /home/erreur32/Bash3lper/ > /home/www/html/_page/GITSTAT/Bash3lper/gitinspector/index.html >/dev/null 2>&1
|
||||
2 * * * * /usr/local/bin/gitstats /home/erreur32/Bash3lper/ /home/www/html/_page/GITSTAT/Bash3lper/gitstats/ >/dev/null 2>&1
|
||||
2 * * * * /usr/local/bin/repostat --no-browser --copy-assets /home/erreur32/Bash3lper /home/www/html/_page/GITSTAT/Bash3lper/repostat/ >/dev/null 2>&1
|
||||
2 * * * * sudo /usr/local/bin/git_stats generate --path=/home/erreur32/Bash3lper/ --out-path=/home/www/html/_page/GITSTAT/Bash3lper/git_stats/ >/dev/null 2>&1
|
||||
#5 4 * * * /usr/bin/gitstats /root/MOTDs32/ /home/www/html/MOTDs32/Stats/ && curl -fsS --retry 3 https://x20.echosystem.fr/ping/2494d5a8-998f-4322-a298-c9b5e5265bbd > /dev/null
|
||||
############################################################
|
||||
# MAJ
|
||||
@monthly /home/tools/certbot/certbot-auto renew --apache --force-renew
|
||||
@weekly /etc/ipset-blacklist/update-blacklist.sh /etc/ipset-blacklist/ipset-blacklist.conf
|
||||
@daily /home/tools/SH/mail-fail2ban-report.sh
|
||||
#@weekly /usr/sbin/tiger -H -E -l /home/www-adm1n/tiger/ && chown www-data /home/www-adm1n/tiger/ -R
|
||||
@weekly /home/tools/SH/updater-netdata.sh
|
||||
@weekly /home/tools/SH/optimize-db.sh
|
||||
#@weekly failstatus
|
||||
|
||||
#@daily /bin/bash /home/tools/SH/updater-youtub-dl.sh 2>&1
|
||||
#@daily /home/tools/SH/updater-youtub-dl.sh
|
||||
#*/5 * * * * /home/tools/SH/updater-youtub-dl.sh
|
||||
####################################
|
||||
## Apache ## Clean cache blog.echosystem.fr
|
||||
#@daily wget --spider -qO- "https://blog.echosystem.fr/.admin_/_rss.ajax.php?guid=ea62141e847746780f11ece6dabcaa7b23cd5b64&refresh_all"
|
||||
#*/4 * * * * chown mysql:adm /var/log/mysql/error.log
|
||||
#*/4 * * * * chown www-data:adm /var/log/apache2 -Rf
|
||||
#*/4 * * * * chmod 754 /var/log/apache2 -Rf
|
||||
|
||||
############################# BACKUP
|
||||
# ┌────────── minute (0 - 59)
|
||||
# │ ┌──────── hour (0 - 23)
|
||||
# │ │ ┌────── day of month (1 - 31)
|
||||
# │ │ │ ┌──── month (1 - 12)
|
||||
# │ │ │ │ ┌── day of week (0 - 6 => Sunday - Saturday, or 1 - 7 => Monday - Sunday)
|
||||
# │ │ │ │ │
|
||||
# ↓ ↓ ↓ ↓ ↓
|
||||
# * * * * * command to be executed
|
||||
# m h dom mon dow command
|
||||
|
||||
### BACKUP
|
||||
#@monthly /bin/cp -f /usr/share/nano/* /home/backup/Backup-nano/
|
||||
@monthly /home/tools/SH/Cron-package-installed.sh &>/dev/null
|
||||
@monthly /bin/cat /root/.bash_history > /home/backup/.bash_history_back
|
||||
@monthly /home/tools/SH/Cronall.sh > /home/backup/Crontab-save
|
||||
@monthly /bin/bash /home/tools/SH/Backup-Home-tools.tar.gz.sh
|
||||
# Tous les Lundi
|
||||
1 1 * * 1 /bin/bash /home/tools/SH/Backup-Sql-date.sh
|
||||
2 2 * * 1 /bin/bash /home/tools/SH/Backup-Root.tar.gz.sh
|
||||
3 3 * * 1 /bin/bash /home/tools/SH/Backup-Home-git.tar.gz.sh
|
||||
4 4 * * 1 /bin/bash /home/tools/SH/Backup-Home-www.tar.gz.sh
|
||||
4 5 * * 1 /bin/bash /home/tools/SH/Backup-Home-www-grav.tar.gz.sh
|
||||
# Tous les 2 et 20 du mois
|
||||
5 5 2,20 * * /bin/bash /home/tools/SH/Backup-Home-www-ADM1N.tar.gz.sh
|
||||
# Tous les 12 et 14 du mois
|
||||
11 5 12 * * /bin/bash /home/tools/SH/Cron-backup-ECHO-btsync-START
|
||||
11 6 14 * * /bin/bash /home/tools/SH/Cron-backup-ECHO-btsync-STOP
|
||||
33 3 28 * * /bin/bash /home/tools/SH/Backup-Home-youtube.tar.gz.sh
|
||||
# Tous les 2 du mois
|
||||
1 1 2 * * /bin/bash /home/tools/SH/Backup-BIN.tar.gz.sh
|
||||
2 2 2 * * /bin/bash /home/tools/SH/Backup-ETC.tar.gz.sh
|
||||
3 3 2 * * /bin/bash /home/tools/SH/Backup-VAR-LOG.tar.gz.sh
|
||||
4 4 2 * * /bin/bash /home/tools/SH/Backup-VAR.tar.gz.sh
|
||||
6 6 2 * * /bin/bash /home/tools/SH/Backup-Home-erreur32.tar.gz.sh
|
||||
#53 5 27 * * /bin/bash /home/tools/SH/Backup-Home-ircd.tar.gz.sh
|
||||
|
||||
#38 * * * * chown www-data /var/log/piwik-archive.log && su -s /bin/bash www-data -c "/usr/bin/php /home/www/html/piwik/console core:archive --url=https://echosystem.fr/PiwM/ --force-all-websites" > /var/log/piwik-archive.log
|
||||
#41 */6 * * * /etc/init.d/apache2 restart &> /dev/null
|
||||
|
||||
13 */6 * * * su -s /bin/bash www-data -c "/usr/bin/php /home/www/html/piwik/console core:archive --url=https://echosystem.fr/PiwM/" > /var/log/piwik-archive.log
|
||||
|
||||
*/21 * * * * su -s /bin/bash www-data -c "php /home/www/RSS/app/actualize_script.php" > /tmp/RSS.log 2>&1
|
||||
### GOACCESS
|
||||
53 * * * * /bin/zcat -f /var/log/apache2/access.log* | /usr/local/bin/goaccess --log-format=VCOMBINED -a -o /home/www-adm1n/MonitorinG/Goaccess/All-log-goa.conf.html --html-report-title All-log-goa.conf > /dev/null 2>&1
|
||||
57 * * * * su -s /bin/bash www-data -c "/usr/local/bin/goaccess -a -o /home/www-adm1n/MonitorinG/Goaccess/goaccess-cron.html"
|
||||
57 * * * * /bin/zcat -f /var/log/apache2/access.youtube.oueb.net.log* | /usr/bin/goaccess - --no-global-config --log-format=VCOMBINED -o /home/www-adm1n/MonitorinG/Goaccess/youtube.oueb.net.html --html-report-title youtube.oueb.net >/dev/null 2>&1
|
||||
58 * * * * /bin/zcat -f /var/log/apache2/access.log* | grep -F "rss " | grep -vE '(wallabag|public|blog|ns336667)' | /usr/bin/goaccess - --no-global-config --log-format=VCOMBINED -o /home/www-adm1n/MonitorinG/Goaccess/rss-all.html --html-report-title rss-all >/dev/null 2>&1
|
||||
59 * * * * /bin/zcat -f /var/log/apache2/access.breakingbad.echosystem.fr.log* | /usr/bin/goaccess - -p /etc/goaccess-breakingbad.conf --log-format=VCOMBINED -o /home/www-adm1n/MonitorinG/Goaccess/breakingbad.html --html-report-title breakingbad >/dev/null 2>&1
|
||||
# /home/tools/SH/goaccess-mail.sh
|
||||
# grep -h "/rss.php " /var/log/apache2/access.log* | /usr/bin/goaccess --log-format=COMBINED -o /home/www-adm1n/MonitorinG/Goaccess/rss-blog.html
|
||||
####
|
||||
|
||||
* * * * * cd /home/www/html/Grav;su -s /bin/bash www-data -c "/usr/bin/php bin/grav scheduler" 1>> /dev/null 2>&1
|
||||
*/3 * * * * su root -c "/usr/bin/php -q /home/www-adm1n/phpservermon-git/cron/status.cron.php" > /dev/null
|
||||
#*/3 * * * * su -s /bin/bash www-data -c "/usr/bin/php -q /home/www-adm1n/phpservermon-git/cron/status.cron.php" > /dev/null
|
||||
41 * * * * su -s /bin/bash www-data -c "/usr/bin/php -q /home/www-adm1n/MonitorinG/loadavg/logger.php" >/dev/null
|
||||
*/5 * * * * su -s /bin/bash www-data -c "/bin/bash /home/www-adm1n/StatRRD/statRRD graph" > /dev/null
|
||||
|
||||
*/5 * * * * su -s /bin/bash www-data -c "/usr/bin/php /home/www/info_social/protected/yii queue/run" >/dev/null 2>&1
|
||||
*/5 * * * * su -s /bin/bash www-data -c "/usr/bin/php /home/www/info_social/protected/yii cron/run" >/dev/null 2>&1
|
||||
#*/3 * * * * perl /usr/local/bin/rrd_traffic.perl >/dev/null
|
||||
48 * * * * /usr/bin/vnstat -u &>/dev/null
|
||||
|
||||
|
||||
*/5 * * * * /usr/bin/motds32 -g >/dev/null 2>&1
|
233
install.sh
233
install.sh
|
@ -33,6 +33,24 @@
|
|||
# # bash install.sh
|
||||
#
|
||||
#
|
||||
################################################################################
|
||||
LSB=/usr/bin/lsb_release
|
||||
|
||||
## DEBUG
|
||||
|
||||
readonly PROGNAME=$(basename $0)
|
||||
readonly PROGDIR=$(readlink -m $(dirname $0))
|
||||
readonly PROGDIRSCRIPT="$(readlink -m $(dirname $0))/scripts"
|
||||
readonly ARGS="$@"
|
||||
|
||||
## debug
|
||||
set -e -u -o pipefail
|
||||
IFS=$'\n\t'
|
||||
on_error() { echo "Error on or near line $1; exiting with status $2"; exit "$2"; }
|
||||
|
||||
trap 'on_error ${LINENO} $?' ERR
|
||||
|
||||
|
||||
################################################################################
|
||||
# Make sure only root can run our script
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
|
@ -40,7 +58,10 @@ if [[ $EUID -ne 0 ]]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
crontab -l > $PROGDIR/crontab.backup
|
||||
|
||||
pathscript32="$(cd "$(dirname "$0")" && pwd)"
|
||||
cronmotd="*/5 * * * * /usr/bin/motds32 -g >/dev/null 2>&1"
|
||||
|
||||
## clean terminal
|
||||
BG_BLUE="$(tput setab 4)"
|
||||
|
@ -51,7 +72,8 @@ FG_WHITE="$(tput setaf 7)"
|
|||
# Save screen
|
||||
tput smcup
|
||||
# Display menu until selection == 0
|
||||
while [[ $REPLY != 0 ]]; do
|
||||
#while [[ $REPLY != 0 ]]; do
|
||||
while [[ $ARGS != 0 ]]; do
|
||||
echo -n ${BG_BLACK}${FG_WHITE}
|
||||
clear
|
||||
echo -e "\e[33;3m"
|
||||
|
@ -114,26 +136,8 @@ echo -e " \e[34m- build-essential \e[1;31mSelect option 1 \e[91m Missing pa
|
|||
|
||||
check_depend || echo -e "\e[34m Check required dependencies ! (need to be installed)"
|
||||
|
||||
|
||||
echo -e "\n\e[32;3m YOU CAN SKIP (auto) install if you want"
|
||||
echo -e "\n\e[92m Please Select:"
|
||||
echo -e " 1. \e[97m(auto) Install Missing Package\e[92m"
|
||||
echo -e " 2. \e[97mInstallation MOTDs32 script\e[92m"
|
||||
echo -e " 3. \e[97mUpdate MOTDs32 script\e[92m"
|
||||
echo -e " 4. \e[97mUninstall completly MOTDs32 script\e[92m"
|
||||
echo -e " 0. \e[97m(Enter or any key) to Quit\n\e[33;3m"
|
||||
read -p " Enter selection [0-3] or (Enter) to Quit > " selection
|
||||
echo -e "\e[97m"
|
||||
|
||||
# Clear area beneath menu
|
||||
tput cup 10 0
|
||||
echo -n ${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"
|
||||
Check_install_package(){
|
||||
echo -e " \e[32m install missing package ...\e[0m\n"
|
||||
apt-get install --allow-unauthenticated -y build-essential ntp figlet postfix sasl2-bin
|
||||
echo -e "\n\e[34m - apt-get installation build-essential ntp figlet \e[0m>> Succesfull"
|
||||
if [ -f "/usr/bin/motds32" ]
|
||||
|
@ -152,15 +156,16 @@ tput cup 11 0
|
|||
then
|
||||
echo -e " \e[31m code bash missing\e[0m"
|
||||
echo "cat /etc/motd" >> ~/.bashrc
|
||||
echo "/etc/motds32/Stats32" >> ~/.bashrc
|
||||
echo -e "\e[92m - Code bash \e[0madded.\n"
|
||||
else
|
||||
grepmot=`grep '/etc/motd' ~/.bashrc`
|
||||
echo -e " \e[1;30m Code bash found: \e[0m>>\e[0m $grepmot \e[0m<<\n"
|
||||
# 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"
|
||||
fi
|
||||
|
||||
# Check if MOTDs32 is already add
|
||||
if test ! -d /etc/motds32; then mkdir -p /etc/motds32; fi
|
||||
if test ! -d /etc/motds32; then mkdir -p /etc/motds32; fi
|
||||
|
||||
if [ -f "/etc/motds32/Stats32" ]
|
||||
then
|
||||
|
@ -180,6 +185,7 @@ tput cup 11 0
|
|||
echo -e " -->\e[34m figlet&font \e[92mOK\e[0m"
|
||||
fi
|
||||
|
||||
|
||||
# Check if motd is installed correctly
|
||||
if [ -f "/usr/bin/motd" ]
|
||||
then
|
||||
|
@ -192,24 +198,29 @@ tput cup 11 0
|
|||
if crontab -l | grep -q '/usr/bin/motds32'; then
|
||||
echo -e " \e[34m -Cron \e[0m>> already added.\e[0m"
|
||||
else
|
||||
(crontab -l ; echo "*/5 * * * * /usr/bin/motds32 -g >/dev/null 2>&1")| crontab -
|
||||
(crontab -l ; echo $cronmotd)| crontab -u root -
|
||||
# (crontab -l ; echo "*/5 * * * * /usr/bin/motds32 -g >/dev/null 2>&1")| crontab -
|
||||
echo -e "\e[34m - Cron added.\e[0m"
|
||||
fi
|
||||
## Generate first stats
|
||||
if test -f /usr/bin/motds32; then /usr/bin/motds32 -g; fi
|
||||
|
||||
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 0 to exit)\e[0m"
|
||||
printf "\n \e[1;33m (Or any key to go back.)\e[0m"
|
||||
;;
|
||||
2) echo -n " Git " ; cd $pathscript32 && git pull ; echo -e "\n\e[92m" ;
|
||||
grepmot="cat /etc/motd"
|
||||
echo -e "\n\n\e[34m \e[92m Installation PACKAGE completed!\e[0m \n\n\n You can install \e[1;33m MOTDs32\n\e[92m Use: \033[1;30m option 2\e[0m \n\e[0m\n"
|
||||
printf "\n \e[1;33m (Press 0 to exit) Or any key to go back."
|
||||
|
||||
}
|
||||
#Check_install_package
|
||||
|
||||
Motds32_install(){
|
||||
echo -n " Git " ; cd $pathscript32 && git pull ; echo -e "\n\e[92m" ;
|
||||
grepmot="cat /etc/motd"
|
||||
# if [ `grep -c "cat /etc/motd" ~/.bashrc` == 0 ]
|
||||
if [ $(grep -c "cat /etc/motd" ~/.bashrc) == 0 ]
|
||||
then
|
||||
echo -e "\e[31m code bash missing\e[0m"
|
||||
echo $grepmot >> ~/.bashrc
|
||||
echo -e "\e[92m - Code bash \e[0madded.\n"
|
||||
echo "/etc/motds32/Stats32" >> ~/.bashrc
|
||||
echo -e "\e[92m - Code bash \e[0madded.\n"
|
||||
else
|
||||
# sed -i '/cat \/etc\/motd/d' ~/.bashrc
|
||||
# grepmot=$(grep "/etc/motd" ~/.bashrc)
|
||||
|
@ -217,6 +228,15 @@ tput cup 11 0
|
|||
echo -e " -->\e[34m Code bash: \e[92mOK\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 figlet&font \e[92mOK\e[0m"
|
||||
fi
|
||||
|
||||
# Check if MOTDs32 is already add
|
||||
if test ! -d /etc/motds32; then mkdir -p /etc/motds32; fi
|
||||
|
||||
|
@ -261,9 +281,10 @@ tput cup 11 0
|
|||
## Install Crontab
|
||||
if crontab -l | grep -q '/usr/bin/motds32'; then
|
||||
echo -e "\e[34m - Cron \e[0m>> already added.\e[0m"
|
||||
/usr/bin/motds32 -g
|
||||
/usr/bin/motds32 -g
|
||||
else
|
||||
(crontab -l ; echo "*/5 * * * * /usr/bin/motds32 -g >/dev/null 2>&1")| crontab -
|
||||
(crontab -l ; echo $cronmotd)| crontab -u root -
|
||||
# (crontab -l ; echo "*/5 * * * * /usr/bin/motds32 -g >/dev/null 2>&1")| crontab -
|
||||
echo -e "\e[34m - Cron added.\e[0m"
|
||||
fi
|
||||
## Generate first stats
|
||||
|
@ -272,15 +293,25 @@ tput cup 11 0
|
|||
echo -e "\n\n\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"
|
||||
printf "\n \e[1;33m (Press any key to exit.)\e[0m"
|
||||
;;
|
||||
3) echo -n " Git " ; cd $pathscript32 && git pull ; echo -e "\n\e[92m" ;
|
||||
if [ -f "/etc/motds32/Stats32" ]
|
||||
|
||||
}
|
||||
|
||||
# Motds32_install
|
||||
|
||||
|
||||
Motds32_update(){
|
||||
echo -n " Git " ; cd $pathscript32 && git pull ; echo -e "\n\e[92m" ;
|
||||
if [ $(grep -c "cat /etc/motd" ~/.bashrc) == 0 ]
|
||||
then
|
||||
echo -e " -->\e[34m Stats32 \e[92mOK\e[0m"
|
||||
cp -f $pathscript32/Stats32 /etc/motds32/Stats32
|
||||
echo -e "\e[31m code bash missing\e[0m"
|
||||
echo $grepmot >> ~/.bashrc
|
||||
echo "/etc/motds32/Stats32" >> ~/.bashrc
|
||||
echo -e "\e[92m - Code bash \e[0madded.\n"
|
||||
else
|
||||
cp -f $pathscript32/Stats32 /etc/motds32/Stats32
|
||||
echo -e " -->\e[32;4m Stats32 \e[92mOK\e[0m"
|
||||
# sed -i '/cat \/etc\/motd/d' ~/.bashrc
|
||||
# grepmot=$(grep "/etc/motd" ~/.bashrc)
|
||||
echo -e " \e[32;1m Code bash found: \e[0m>>\e[0m $grepmot \e[0m<<\n"
|
||||
echo -e " -->\e[34m Code bash: \e[92mOK\e[0m"
|
||||
fi
|
||||
if [ -f "/usr/bin/motds32" ]
|
||||
then
|
||||
|
@ -293,40 +324,109 @@ tput cup 11 0
|
|||
echo -e "\e[32;4m - Make install first !\e[0m\n"
|
||||
echo -e "\n\e[1;33m (Press any key.)\e[0m"
|
||||
fi
|
||||
if [ -f "/etc/motds32/Stats32" ]
|
||||
then
|
||||
echo -e " -->\e[34m Stats32 \e[92mOK\e[0m"
|
||||
cp -f $pathscript32/Stats32 /etc/motds32/Stats32
|
||||
else
|
||||
cp -f $pathscript32/Stats32 /etc/motds32/Stats32
|
||||
echo -e " -->\e[32;4m Stats32 \e[92mOK\e[0m"
|
||||
fi
|
||||
|
||||
# generate new stat
|
||||
# motd -g
|
||||
/usr/bin/motds32 -g
|
||||
;;
|
||||
4) echo -e "\n\e[34m Unistall of MOTDs32 in progress... \e[0m\n"
|
||||
|
||||
|
||||
}
|
||||
|
||||
# Motds32_update
|
||||
|
||||
|
||||
Motds32_remove(){
|
||||
echo -e "\n\e[34m Unistall of MOTDs32 in progress... \e[0m\n"
|
||||
## remove file and directory
|
||||
make uninstall
|
||||
rm /etc/motds32/ -Rf
|
||||
rm -f /usr/bin/motd
|
||||
rm /var/cache/motds32/ -Rf
|
||||
|
||||
# make uninstall
|
||||
## remove cron
|
||||
if crontab -l | grep -q '/usr/bin/motds32'; then
|
||||
echo -e "\n \e[92m Cron localized\n"
|
||||
crontab -l | grep -v '*/5 * * * * /usr/bin/motds32 -g >/dev/null 2>&1' | crontab -u root -
|
||||
echo -e " \e[92m Cron removed\n"
|
||||
else
|
||||
echo -e "\n \e[93m Cron not find\n"
|
||||
fi
|
||||
|
||||
if [ `grep -c /etc/motd ~/.bashrc` == 0 ]
|
||||
if crontab -l | grep -q '/usr/bin/motds32'
|
||||
then
|
||||
echo " Code bash removed"
|
||||
echo -e "\n \e[94m Cron localized\n"
|
||||
crontab -l | grep -v $cronmotd| crontab -u root -
|
||||
# crontab -l | grep -v "*/5 * * * * /usr/bin/motds32 -g >/dev/null 2>&1" | crontab -u root -
|
||||
echo -e " \e[35m Cron removed\n"
|
||||
else
|
||||
echo " Code bash found"
|
||||
sed -i '/cat \/etc\/motd/d' ~/.bashrc
|
||||
sed -i '/cat \/usr\/bin\/motds32 -g/d' ~/.bashrc
|
||||
echo -e "\e[92m Code .bashrc removed.\e[0m"
|
||||
grep -n '/etc/motd' ~/.bashrc
|
||||
echo -e "\n \e[35m Cron OK\n"
|
||||
fi
|
||||
|
||||
echo -e "\n\e[92m Script MOTDs32 has been completly removed \e[0m"
|
||||
printf "\n \e[1;33m (Press any key.)\e[0m"
|
||||
;;
|
||||
|
||||
if [ `grep -c motd ~/.bashrc` == 0 ]
|
||||
then
|
||||
echo -e " \e[35m Code bash removed"
|
||||
else
|
||||
echo -e " \e[34mCode bash found"
|
||||
sed -i '/cat \/etc\/motd/d' ~/.bashrc
|
||||
sed -i '\/etc\/motds32\/Stats32/d' ~/.bashrc
|
||||
echo -e "\e[92m Code .bashrc removed.\e[0m"
|
||||
grep -n '/etc/motd' ~/.bashrc
|
||||
echo -e "\e[0m"
|
||||
fi
|
||||
|
||||
make uninstall >/dev/null
|
||||
|
||||
if [ -d "/etc/motds32" ]
|
||||
then
|
||||
rm /etc/motds32/ -Rf
|
||||
fi
|
||||
|
||||
if [ -f "/var/cache/motds32" ]
|
||||
then
|
||||
rm /usr/bin/motd /var/cache/motds32/ -Rf
|
||||
fi
|
||||
|
||||
if [ -f "/etc/motd.orig" ]
|
||||
then
|
||||
mv /etc/motd.orig /etc/motd
|
||||
fi
|
||||
echo -e "\n\e[35m Motds32 Files... Removed, all good!"
|
||||
# if test ! -e /etc/motd.orig; then mv /etc/motd.orig /etc/motd; fi
|
||||
# if test ! -d /var/cache/motds32; then rm /usr/bin/motd /var/cache/motds32/ -Rf; fi
|
||||
|
||||
echo -e "\n\e[92m Script MOTDs32 has been completly removed \e[0m"
|
||||
printf "\n\n \e[1;33m (Press any key.)\e[0m"
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
echo -e "\n\e[32;3m YOU CAN SKIP (auto) install if you want"
|
||||
echo -e "\n\e[92m Please Select:"
|
||||
echo -e " 1. \e[97m(auto) Install Missing Package\e[92m"
|
||||
echo -e " 2. \e[97mInstallation MOTDs32 script\e[92m"
|
||||
echo -e " 3. \e[97mUpdate MOTDs32 script\e[92m"
|
||||
echo -e " 4. \e[97mUninstall completly MOTDs32 script\e[92m"
|
||||
echo -e " 0. \e[97m(Enter or any key) to Quit\n\e[33;3m"
|
||||
read -p " Enter selection [0-3] or (Enter) to Quit > " selection
|
||||
echo -e "\e[97m"
|
||||
|
||||
|
||||
#check_depend
|
||||
|
||||
# Clear area beneath menu
|
||||
tput cup 10 0
|
||||
echo -n ${FG_GREEN}
|
||||
tput ed
|
||||
tput cup 11 0
|
||||
|
||||
case $selection in
|
||||
1) Check_install_package
|
||||
;;
|
||||
2) Motds32_install
|
||||
;;
|
||||
3) Motds32_update
|
||||
#echo -e "\n Installation \e[34mMOTDs32 terminated.\e[0m\n Help? Use: \n \033[1;30m /usr/bin/motds32\n"
|
||||
;;
|
||||
4) Motds32_remove
|
||||
;;
|
||||
0) break
|
||||
;;
|
||||
*) break
|
||||
|
@ -341,4 +441,5 @@ done
|
|||
|
||||
# Restore screen
|
||||
tput rmcup
|
||||
echo "Installation MOTDs32 terminated."
|
||||
echo -e " Installation \e[34mMOTDs32 terminated.\e[0m\n Help? Use: \n \033[1;30m /usr/bin/motds32\n"
|
||||
|
||||
|
|
Loading…
Reference in a new issue