153 lines
3.6 KiB
Bash
Executable File
153 lines
3.6 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Load libraries
|
|
. lib/display.sh
|
|
. lib/filefct.sh
|
|
|
|
# Check gestparc native directory
|
|
#export REPO="/share/services/gestparc"
|
|
|
|
export HOSTNAME=$(hostname)
|
|
|
|
export DATEFORMAT=${DATEFORMAT:-"+%Y/%m/%d-%H:%M:%S-%N"}
|
|
export LOGFILE=${LOGFILE:-"/var/log/$(uname -n)-$(date +%Y%m%d-%H%M).log"}
|
|
|
|
# Authentication
|
|
#authnz()
|
|
#{
|
|
# apt-get install nscd libpam-krb5 libnss-ldap libpam-ldap
|
|
#
|
|
# backupdist /etc/krb5.conf /etc/libnss-ldap.conf /etc/pam_ldap.conf /etc/nsswitch.conf \
|
|
# /etc/pam.d/common-session /etc/pam.d/common-account /etc/pam.d/common-password \
|
|
# /etc/pam.d/common-auth
|
|
# installfile krb5.conf libnss-ldap.conf pam_ldap.conf nsswitch.conf /etc
|
|
# installfile common-session common-account common-password common-auth /etc/pam.d
|
|
#
|
|
# /etc/init.d/nscd restart
|
|
#}
|
|
|
|
# Users (from Ldap)
|
|
#add_users()
|
|
#{
|
|
# backupdist /etc/passwd /etc/shadow /etc/group
|
|
# sed -i -e '/^fatal/d' /etc/passwd /etc/shadow /etc/group
|
|
# echo "+kroot::::::" >> /etc/passwd
|
|
# echo "+kroot::::::::" >> /etc/shadow
|
|
#}
|
|
|
|
# Locale
|
|
conf_locale()
|
|
{
|
|
backupdist /etc/locale.gen
|
|
sed -i "/^# en_US.UTF-8 /s/^# //" /etc/locale.gen
|
|
locale-gen
|
|
}
|
|
|
|
# Additionnal packages (some are necessary to that script to end successfully)
|
|
install_pkg()
|
|
{
|
|
apt install -y $INSTLIST
|
|
}
|
|
|
|
# NTP
|
|
conf_ntp()
|
|
{
|
|
backupdist /etc/ntp.conf
|
|
installfile ntp.conf /etc/ntp.conf
|
|
}
|
|
|
|
# SSH server
|
|
conf_ssh()
|
|
{
|
|
backupdist /etc/ssh/ssh{,d}_config
|
|
sed -i -e '/^#PermitRootLogin/s/^#//' /etc/ssh/sshd_config
|
|
sed -i -e '/^PermitRootLogin /s/ .*/ yes/' /etc/ssh/sshd_config
|
|
/etc/init.d/ssh restart || true
|
|
$BASEGPDIR/ssh/getpubkey.sh
|
|
installfile ssh_config /etc/ssh/ssh_config
|
|
}
|
|
|
|
# Profile
|
|
install_profile()
|
|
{
|
|
installfile ansi_shadow.flf /usr/share/figlet/ansi_shadow.flf
|
|
for usr in /root /home/*; do
|
|
backupdist $usr/{,.}profile $usr/.bashrc
|
|
installfile {{.,}profile,.bashrc} $usr/
|
|
done
|
|
backupdist /etc/motd
|
|
installfile motd /etc/motd
|
|
}
|
|
|
|
# Supervision
|
|
patch_snmp()
|
|
{
|
|
backupdist /etc/snmp/snmpd.conf /etc/default/snmpd /lib/systemd/system/snmpd.service /etc/init.d/snmpd
|
|
installfile snmpd.conf /etc/snmp/snmpd.conf
|
|
installfile snmpd.init /etc/init.d/snmpd
|
|
[[ -e /lib/systemd/system/snmpd.service ]] &&
|
|
installfile snmpd.service /lib/systemd/system/snmpd.service
|
|
/etc/init.d/snmpd restart || true # error on systemd systems requiring reboot wich we'll do anyway after that script
|
|
}
|
|
|
|
install_mk-agent()
|
|
{
|
|
apt install -y $BASEGPDIR/mk_agents/check-mk-agent_${MKVERSION}_all.deb
|
|
backupdist /etc/xinetd.d/check_mk
|
|
installfile check_mk /etc/xinetd.d/check_mk
|
|
/etc/init.d/xinetd restart
|
|
}
|
|
|
|
# Syslog
|
|
conf_syslog()
|
|
{
|
|
backupdist /etc/rsyslog.conf
|
|
installfile rsyslog.conf /etc/rsyslog.conf
|
|
/etc/init.d/rsyslog restart
|
|
}
|
|
|
|
# Mail
|
|
conf_mail()
|
|
{
|
|
installfile postfix.cf /etc/postfix/main.cf
|
|
sed -i -e "s/#HOSTNAME#/$HOSTNAME/g" /etc/postfix/main.cf
|
|
/etc/init.d/postfix restart
|
|
}
|
|
|
|
|
|
# ======================
|
|
# ==== Main Program ====
|
|
# ======================
|
|
|
|
# Vérifie qu'on soit root
|
|
if [[ $EUID -ne 0 ]];
|
|
prnt E "Ce script doit être démarré en root. Arrêt."
|
|
exit 1
|
|
fi
|
|
|
|
# Chargement de la configuration
|
|
[[ -s conf/init.sh.conf ]] && . conf/init.sh.conf || (
|
|
prnt E "Impossible de charger la configuration."
|
|
exit 1
|
|
)
|
|
|
|
|
|
|
|
upgrade_dist
|
|
[[ ! $PVEHST ]] && install_ceph && conf_ceph
|
|
[[ ! $PVEHST ]] && apt_blacklist
|
|
#[[ ! $PVEHST ]] && authnz
|
|
#[[ ! $PVEHST ]] && add_users
|
|
conf_locale
|
|
install_pkg
|
|
conf_ntp
|
|
conf_ssh
|
|
install_profile
|
|
patch_snmp
|
|
install_mk-agent
|
|
conf_syslog
|
|
conf_mail
|
|
|
|
echo "That's all folks !"
|
|
echo "Après vérification des logs, il est recommandé de redémarrer la machine..."
|