several improvement and armonisation in filefct.sh, module auth and patch_snmp improved
This commit is contained in:
2
init.sh
2
init.sh
@@ -36,7 +36,7 @@ export LC_ALL=C
|
||||
export LANG=C
|
||||
|
||||
# Version of init
|
||||
export VERSION="0.99.14"
|
||||
export VERSION="0.99.15"
|
||||
|
||||
# Store script's path (realpath -s resolve symlinks if init.sh is a symlink)
|
||||
export MYPATH=$(dirname $(realpath -s $0))
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
# ------------------------------------------------------------------------------
|
||||
# Backup original installation files
|
||||
# (or any old files if runned several time on same file)
|
||||
backupdist()
|
||||
backup_dist()
|
||||
{
|
||||
if [[ $# -lt 1 ]]; then
|
||||
prnt E "backupdist(): At least one argument is required."
|
||||
@@ -51,7 +51,7 @@ export -f backupdist
|
||||
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Select source file according to our priority mechanisme
|
||||
# Select source file according to our priority mechanism
|
||||
select_file()
|
||||
{
|
||||
local infile=$1
|
||||
@@ -69,10 +69,29 @@ select_file()
|
||||
}
|
||||
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Select source directory according to our priority mechanism
|
||||
select_directory()
|
||||
{
|
||||
local indir=$1
|
||||
if [[ -d $MYPATH/repo/hosts/$HOSTNAME/$indir ]]; then
|
||||
local source="$MYPATH/repo/hosts/$HOSTNAME/$indir"
|
||||
elif [[ -d $MYPATH/repo/common/$indir ]]; then
|
||||
local source="$MYPATH/repo/common/$indir"
|
||||
else
|
||||
# Not found in repository, we expect full name
|
||||
local source="$indir"
|
||||
fi
|
||||
unset indir
|
||||
echo $source
|
||||
unset source
|
||||
}
|
||||
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Install file to the host (specific first then general)
|
||||
# Todo: implement wildcard support
|
||||
installfile()
|
||||
install_file()
|
||||
{
|
||||
local filelist=""
|
||||
local i=0
|
||||
@@ -123,7 +142,7 @@ export -f installfile
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Add the content of a file at the end of an other
|
||||
appendfile()
|
||||
append_file()
|
||||
{
|
||||
local srcfile=$(select_file $1)
|
||||
local dstfile=$2
|
||||
@@ -148,7 +167,7 @@ export -f appendfile
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# determine if a directory is empty
|
||||
isdirempty()
|
||||
is_dir_empty()
|
||||
{
|
||||
dir=$1
|
||||
|
||||
@@ -172,7 +191,7 @@ export -f isdirempty
|
||||
# ------------------------------------------------------------------------------
|
||||
# copy and patch a file replacing all @var@ by the corresponding value in
|
||||
# the environment or the variable list given in parameter
|
||||
patchfile()
|
||||
patch_file()
|
||||
{
|
||||
local srcfile=$(select_file $1) && shift
|
||||
local dstfile=$1 && shift
|
||||
@@ -217,7 +236,7 @@ export -f patchfile
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Put a small header in a file showing it have been automatically modified
|
||||
tagfile()
|
||||
tag_file()
|
||||
{
|
||||
for f in $@; do
|
||||
local text="# File automatically modified by init.sh on $(stdtime)."
|
||||
@@ -233,17 +252,60 @@ export -f tagfile
|
||||
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# check a file exists and return error if not
|
||||
# check files exists and return 1 if one do not
|
||||
file_exists()
|
||||
{
|
||||
prnt I "Checking $@ files existance..."
|
||||
for f in $@; do
|
||||
if [[ ! -f $(select_file $f) ]]; then
|
||||
prnt E "file_exists(): The $f file is missing, can't continue."
|
||||
die 10
|
||||
fi
|
||||
echo $f
|
||||
return 1
|
||||
fi
|
||||
done
|
||||
return 0
|
||||
}
|
||||
export -f file_exists
|
||||
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# check if file exists and return error if not
|
||||
file_must_exists()
|
||||
{
|
||||
prnt I "Checking $@ files existance..."
|
||||
local mf=$(file_exists $@)
|
||||
if [[ $? -ne 0 ]]; then
|
||||
prnt E "file_must_exists(): The $mf file is missing, can't continue."
|
||||
die 10
|
||||
fi
|
||||
unset mf
|
||||
}
|
||||
export -f file_must_exists
|
||||
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# check files exists and return 1 if one do not
|
||||
directory_exists()
|
||||
{
|
||||
for d in $@; do
|
||||
if [[ ! -d $(select_directory $d) ]]; then
|
||||
echo $d
|
||||
return 1
|
||||
fi
|
||||
done
|
||||
return 0
|
||||
}
|
||||
export -f directory_exists
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# check if file exists and return error if not
|
||||
directory_must_exists()
|
||||
{
|
||||
prnt I "Checking $@ directories existance..."
|
||||
local md=$(directory_exists $@)
|
||||
if [[ $? -ne 0 ]]; then
|
||||
prnt E "directory_must_exists(): The $md directory is missing, can't continue."
|
||||
die 10
|
||||
fi
|
||||
unset md
|
||||
}
|
||||
export -f directory_must_exists
|
||||
# EOF
|
||||
|
||||
@@ -20,30 +20,51 @@
|
||||
# * DEFAULT_SHELL: The shell to use when creating new users
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
export VER_authnz=0.1.6
|
||||
export VER_authnz=0.2.0
|
||||
export DEP_authnz="upgrade_dist"
|
||||
|
||||
# Users (from Ldap)
|
||||
add_remote_user()
|
||||
{
|
||||
echo "+$1::::::" >> /etc/passwd
|
||||
echo "+$1::::::::" >> /etc/shadow
|
||||
if [[ $(grep "^$1:" /etc/passwd) ]]; then
|
||||
prnt W "A local user with name $1 already exists, adding anyway!"
|
||||
fi
|
||||
if [[ $(grep "^+$1:" /etc/passwd) ]]; then
|
||||
prnt W "The remote user $1 is already declared, nothing to do in passwd."
|
||||
else
|
||||
echo "+$1::::::" >> /etc/passwd
|
||||
prnt I "User $1 added to passwd..."
|
||||
fi
|
||||
if [[ $(grep "^+$1:" /etc/passwd) ]]; then
|
||||
prnt W "The remote user $1 is already connectable, nothing to do in shadow."
|
||||
else
|
||||
echo "+$1::::::::" >> /etc/shadow
|
||||
prnt I "User $1 added to shadow..."
|
||||
fi
|
||||
}
|
||||
|
||||
# Remove users
|
||||
remove_user()
|
||||
{
|
||||
# Using sed is more universal than any distro commands
|
||||
sed -i -e "/^$1/d" /etc/passwd /etc/shadow /etc/group /etc/gshadow
|
||||
if [[ $(grep "^$1:" /etc/{passwd,shadow,group,gshadow}) ]]; then
|
||||
# Using sed is more universal than any distro commands
|
||||
sed -i -e "/^$1:/d" /etc/{passwd,shadow,group,gshadow}
|
||||
else
|
||||
prnt W "User $1 don't exists in auth files, nothing to do."
|
||||
fi
|
||||
}
|
||||
|
||||
# Create a local user
|
||||
create_user()
|
||||
create_local_user()
|
||||
{
|
||||
if [[ $(noerror --noout id $1) != 0 ]]; then
|
||||
prnt I "Creating user $1..."
|
||||
# The following should be replaced by a more universal version
|
||||
useradd --create-home --shell $DEFAULT_SHELL --user-group $1
|
||||
if [[ $(directory_exists home_skell) ]]; then
|
||||
useradd --create-home --shell $DEFAULT_SHELL --user-group $1 \
|
||||
--skell $(select_directory home_skell)
|
||||
else
|
||||
useradd --create-home --shell $DEFAULT_SHELL --user-group $1
|
||||
fi
|
||||
else
|
||||
prnt W "The user $1 already exists. Nothing to do..."
|
||||
fi
|
||||
@@ -52,8 +73,8 @@ create_user()
|
||||
# Authentication
|
||||
authnz()
|
||||
{
|
||||
backupdist /etc/passwd /etc/shadow /etc/group
|
||||
tagfile /etc/passwd /etc/shadow /etc/group
|
||||
backup_dist /etc/passwd /etc/shadow /etc/group
|
||||
tag_file /etc/passwd /etc/shadow /etc/group
|
||||
for usr in $REMOVE_USERS; do
|
||||
prnt I "Removing user $usr..."
|
||||
remove_user $usr
|
||||
@@ -62,14 +83,14 @@ authnz()
|
||||
if [[ $WITH_LDAP_KERB == yes ]]; then
|
||||
pkginst krb5-user libpam-krb5 libnss-ldap libpam-ldap nscd
|
||||
|
||||
backupdist /etc/krb5.conf /etc/libnss-ldap.conf /etc/pam_ldap.conf \
|
||||
backup_dist /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 authnz/krb5.conf authnz/libnss-ldap.conf \
|
||||
install_file authnz/krb5.conf authnz/libnss-ldap.conf \
|
||||
authnz/pam_ldap.conf authnz/nsswitch.conf /etc
|
||||
|
||||
tagfile /etc/krb5.conf /etc/libnss-ldap.conf /etc/pam-ldap.conf
|
||||
tag_file /etc/krb5.conf /etc/libnss-ldap.conf /etc/pam-ldap.conf
|
||||
sed -i -e "s/@REALM@/${REALM^^}/g" -e "s/@DOMAIN@/$REALM/g" \
|
||||
-e "s/@KDC_SERVER@/$KDC_SERVER/" -e "s/@KADM_SERVER@/$KADM_SERVER/" \
|
||||
/etc/krb5.conf
|
||||
@@ -79,8 +100,8 @@ authnz()
|
||||
-e "s/@LDAP_ADM@/$LDAP_ADM/" /etc/pam-ldap.conf
|
||||
|
||||
|
||||
installfile authnz/common-{session,account,password,auth} /etc/pam.d
|
||||
tagfile /etc/pam.d/common-{session,account,password,auth}
|
||||
install_file authnz/common-{session,account,password,auth} /etc/pam.d
|
||||
tag_file /etc/pam.d/common-{session,account,password,auth}
|
||||
|
||||
scv_restart nscd
|
||||
|
||||
@@ -96,7 +117,7 @@ authnz()
|
||||
|
||||
for usr in $LOCAL_USERS; do
|
||||
prnt I "Creating user $usr..."
|
||||
create_user $usr
|
||||
create_local_user $usr
|
||||
done
|
||||
}
|
||||
|
||||
@@ -114,7 +135,7 @@ precheck_authnz()
|
||||
else
|
||||
prnt W "No distant user but LDAP/Kerberos is activated!"
|
||||
fi
|
||||
file_exists auth/{krb5,libnss-ldap,pam_ldap,nsswitch}.conf
|
||||
file_must_exists auth/{krb5,libnss-ldap,pam_ldap,nsswitch}.conf
|
||||
pam/common-{session,account,password,auth}
|
||||
else
|
||||
if [[ -n $REMOTE_USERS ]]; then
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
# Mount points are hardcoded and should bet set differently
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
export VER_conf_ceph="0.0.3"
|
||||
export VER_conf_ceph="0.0.4"
|
||||
export DEP_conf_ceph="upgrade_dist"
|
||||
|
||||
conf_ceph()
|
||||
@@ -34,8 +34,8 @@ conf_ceph()
|
||||
# hosts files required for Ceph bootstrap when DNS not yet started
|
||||
if [[ ! $(grep "# Ceph" /etc/hosts) ]]; then
|
||||
prnt I "Adding server list to /etc/hosts"
|
||||
backupdist /etc/hosts
|
||||
tagfile /etc/hosts
|
||||
backup_dist /etc/hosts
|
||||
tag_file /etc/hosts
|
||||
echo >> /etc/hosts
|
||||
echo "# Ceph servers:" >> /etc/hosts
|
||||
for srv in $CEPH_SRV_NAMES; do
|
||||
@@ -47,7 +47,7 @@ conf_ceph()
|
||||
prnt W "Ceph servers already in /etc/hosts, nothing to do"
|
||||
fi
|
||||
|
||||
backupdist /etc/fstab
|
||||
backup_dist /etc/fstab
|
||||
prnt I "Adding ceph entries to /etc/fstab"
|
||||
fstabchanged=true
|
||||
echo >> /etc/fstab
|
||||
@@ -63,7 +63,7 @@ conf_ceph()
|
||||
elif [[ $CEPH_STATUS == smb ]]; then
|
||||
pkginst smbclient
|
||||
|
||||
backupdist /etc/fstab
|
||||
backup_dist /etc/fstab
|
||||
prnt I "Adding Samba entries to /etc/fstab"
|
||||
fstabchanged=true
|
||||
echo >> /etc/fstab
|
||||
@@ -90,7 +90,7 @@ conf_ceph()
|
||||
fi
|
||||
|
||||
if [[ $fstabchanged == true ]]; then
|
||||
tagfile /etc/fstab
|
||||
tag_file /etc/fstab
|
||||
fi
|
||||
unset fstabchanged
|
||||
|
||||
|
||||
@@ -20,14 +20,14 @@
|
||||
# Character table (ISO or UTF)
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
export VER_conf_locale="0.1.3"
|
||||
export VER_conf_locale="0.1.5"
|
||||
|
||||
conf_locale()
|
||||
{
|
||||
pkginst locales locales-all
|
||||
local gen_fname=/etc/locale.gen
|
||||
backupdist $gen_fname
|
||||
tagfile $gen_fname
|
||||
backup_dist $gen_fname
|
||||
tag_file $gen_fname
|
||||
|
||||
# Removing locales not in the list
|
||||
prnt I "Deactivating initial locales from installation..."
|
||||
@@ -49,16 +49,18 @@ conf_locale()
|
||||
prnt I "Regenerating locales cache..."
|
||||
locale-gen
|
||||
|
||||
prnt I "Definingdsystem language..."
|
||||
[[ ! $SYSLOCALE ]] &&
|
||||
prnt I "Defining system language..."
|
||||
[[ -z $SYSLOCALE ]] &&
|
||||
export SYSLOCALE=C
|
||||
|
||||
local sys_fname=/etc/default/locale
|
||||
backupdist $sys_fname
|
||||
tagfile $sys_fname
|
||||
backup_dist $sys_fname
|
||||
tag_file $sys_fname
|
||||
echo "LANG=$SYSLOCALE" >> $sys_fname
|
||||
|
||||
# We define all LC_* but LC_ALL as recommended by GNU
|
||||
for cfg in ADDRESS IDENTIFICATION MEASUREMENT MONETARY NAME NUMERIC PAPER \
|
||||
TELEPHONE TIME; do
|
||||
TELEPHONE TIME; do
|
||||
echo "LC_$cfg=$SYSLOCALE" >> $sys_fname
|
||||
done
|
||||
}
|
||||
@@ -72,7 +74,7 @@ precheck_conf_locale()
|
||||
fi
|
||||
|
||||
if [[ -z $SYSLOCALE ]]; then
|
||||
prnt W "No system locale defined, we'll use s."
|
||||
prnt W "No system locale defined, we will use C as default."
|
||||
export SYSLOCALE="C"
|
||||
fi
|
||||
prnt m "The default locale will be $SYSLOCALE"
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
# * MAIL_RELAY: Name of the mail relay server
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
export VER_conf_mail="0.0.5"
|
||||
export VER_conf_mail="0.0.6"
|
||||
export DEP_conf_mail="upgrade_dist"
|
||||
|
||||
conf_mail()
|
||||
@@ -24,12 +24,12 @@ conf_mail()
|
||||
local pfmain="/etc/postfix/main.cf"
|
||||
|
||||
prnt I "Configuration de postfix..."
|
||||
installfile postfix/main.cf $pfmain
|
||||
tagfile $pfmain
|
||||
install_file postfix/main.cf $pfmain
|
||||
tag_file $pfmain
|
||||
sed -i -e "s/@HOSTNAME@/$HOSTNAME/" -e "s/@REALM@/$REALM/" \
|
||||
-e "s/@MAIL_RELAY@/$MAIL_RELAY/" $pfmain
|
||||
|
||||
tagfile /etc/mailname
|
||||
tag_file /etc/mailname
|
||||
echo $HOSTNAME.$REALM > /etc/mailname
|
||||
|
||||
svc_restart postfix
|
||||
@@ -41,7 +41,7 @@ precheck_conf_mail()
|
||||
prnt E "Aucun domaine principal renseigné."
|
||||
die 158
|
||||
fi
|
||||
file_exists postfix/main.cf
|
||||
file_must_exists postfix/main.cf
|
||||
}
|
||||
|
||||
export -f conf_mail
|
||||
|
||||
@@ -20,16 +20,16 @@
|
||||
# * NET{4,6}_MANUAL_FILE_$iface: filename for manual configuration of $iface
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
export VER_conf_syslog="0.0.5"
|
||||
export VER_conf_syslog="0.0.6"
|
||||
|
||||
conf_network()
|
||||
{
|
||||
local if_file="/etc/network/interfaces"
|
||||
backupdist $if_file
|
||||
backup_dist $if_file
|
||||
|
||||
# The interfaces header contain loopback interface declaration
|
||||
installfile interfaces.head $if_file
|
||||
tagfile $if_file
|
||||
install_file interfaces.head $if_file
|
||||
tag_file $if_file
|
||||
|
||||
# First configure IPv4 ifaces
|
||||
local iface=
|
||||
@@ -61,7 +61,7 @@ conf_network()
|
||||
|
||||
elif [[ $(eval echo \$NET4_MODE_$iface) == manual ]]; then
|
||||
local fname=$(eval echo \$NET4_MANUAL_FILE_$iface)
|
||||
appendfile $fname $if_file
|
||||
append_file $fname $if_file
|
||||
unset fname
|
||||
fi
|
||||
done
|
||||
@@ -94,7 +94,7 @@ conf_network()
|
||||
|
||||
elif [[ $(eval echo \$NET6_MODE_$iface) == manual ]]; then
|
||||
local fname=$(eval echo \$NET6_MANUAL_FILE_$iface)
|
||||
appendfile $fname $if_file
|
||||
append_file $fname $if_file
|
||||
unset fname
|
||||
fi
|
||||
done
|
||||
@@ -105,7 +105,7 @@ conf_network()
|
||||
|
||||
precheck_conf_network()
|
||||
{
|
||||
file_exists interfaces.head
|
||||
file_must_exists interfaces.head
|
||||
if [[ -z $IPV4_IFACES ]]; then
|
||||
prnt W "No IPv4 interfaces to configure."
|
||||
else
|
||||
@@ -124,7 +124,7 @@ precheck_conf_network()
|
||||
prnt I " * Interface $iface will use DHCP."
|
||||
;;
|
||||
"manual")
|
||||
file_exists $(eval echo \$NET4_MANUAL_FILE_$iface)
|
||||
file_must_exists $(eval echo \$NET4_MANUAL_FILE_$iface)
|
||||
prnt I " * Interface $iface will use manual IPv4 configuration in a file."
|
||||
;;
|
||||
*)
|
||||
@@ -153,7 +153,7 @@ precheck_conf_network()
|
||||
prnt I " * Interface $iface will use DHCPv6."
|
||||
;;
|
||||
"manual")
|
||||
file_exists $(eval echo \$NET6_MANUAL_FILE_$iface)
|
||||
file_must_exists $(eval echo \$NET6_MANUAL_FILE_$iface)
|
||||
prnt I " * Interface $iface will use manual IPv6 configuration in a file."
|
||||
;;
|
||||
*)
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
# * NTPSERVERS: list of NTP servers
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
export VER_conf_ntp="0.1.4"
|
||||
export VER_conf_ntp="0.1.5"
|
||||
export DEP_conf_ntp=""
|
||||
|
||||
conf_ntp()
|
||||
@@ -28,9 +28,9 @@ conf_ntp()
|
||||
|
||||
prnt I "Installation du fichier de configuration de NTP."
|
||||
local dest="/etc/ntp.conf.work"
|
||||
backupdist /etc/ntp.conf
|
||||
tagfile $dest
|
||||
installfile ntp.conf $dest
|
||||
backup_dist /etc/ntp.conf
|
||||
tag_file $dest
|
||||
install_file ntp.conf $dest
|
||||
local line=""
|
||||
for srv in $NTP_SERVERS; do
|
||||
line="${line}server $srv iburst\n"
|
||||
@@ -52,7 +52,7 @@ precheck_conf_ntp()
|
||||
prnt E "No configured NTP server!"
|
||||
die 151
|
||||
else
|
||||
file_exists ntp.conf
|
||||
file_must_exists ntp.conf
|
||||
prnt m "The NTP servers to be used will be:"
|
||||
for srv in $NTP_SERVERS; do
|
||||
prnt m " * $srv"
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
# none
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
export VER_conf_ssh="0.1.1"
|
||||
export VER_conf_ssh="0.1.2"
|
||||
export DEP_conf_ssh="upgrade_dist"
|
||||
|
||||
conf_ssh()
|
||||
@@ -24,9 +24,9 @@ conf_ssh()
|
||||
|
||||
prnt I "Installation des fichiers de configuration de SSH..."
|
||||
for f in /etc/ssh/ssh{,d}_config; do
|
||||
backupdist $f
|
||||
installfile ssh/$(basename $f) $f
|
||||
tagfile $f
|
||||
backup_dist $f
|
||||
install_file ssh/$(basename $f) $f
|
||||
tag_file $f
|
||||
done
|
||||
sed -i -e "s/@SSHD_PERMITROOT_RANGE@/$SSHD_PERMITROOT_RANGE/" /etc/ssh/sshd_config
|
||||
|
||||
@@ -36,7 +36,7 @@ conf_ssh()
|
||||
|
||||
precheck_conf_ssh()
|
||||
{
|
||||
file_exists ssh/ssh{,d}_config
|
||||
file_must_exists ssh/ssh{,d}_config
|
||||
}
|
||||
|
||||
export -f conf_ssh
|
||||
|
||||
@@ -11,15 +11,15 @@
|
||||
# * SYSLOG_SRV: the syslog server name
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
export VER_conf_syslog="0.0.3"
|
||||
export VER_conf_syslog="0.0.4"
|
||||
|
||||
conf_syslog()
|
||||
{
|
||||
local syslogconf=/etc/rsyslog.conf
|
||||
prnt I "Configuration de rsyslog..."
|
||||
backupdist $syslogconf
|
||||
installfile rsyslog.conf $syslogconf
|
||||
tagfile $syslogconf
|
||||
backup_dist $syslogconf
|
||||
install_file rsyslog.conf $syslogconf
|
||||
tag_file $syslogconf
|
||||
sed -i -e "s/@SYSLOG_SRV@/$SYSLOG_SRV/" $syslogconf
|
||||
svc_restart rsyslog
|
||||
}
|
||||
@@ -30,7 +30,7 @@ precheck_conf_syslog()
|
||||
prnt E "Undeclared syslog server name !"
|
||||
die 181
|
||||
else
|
||||
file_exists rsyslog.conf
|
||||
file_must_exists rsyslog.conf
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
@@ -13,14 +13,14 @@
|
||||
# none
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
export VER_install_chromium="0.0.2"
|
||||
export VER_install_chromium="0.0.3"
|
||||
export DEP_install_chromium="upgrade_dist"
|
||||
|
||||
install_chromium()
|
||||
{
|
||||
# Add Debian Buster repo to sources.list.d directory
|
||||
prnt I "Ajout du dépot Debian Buster aux sources logicielles..."
|
||||
installfile debian_buster.list /etc/apt/sources.list.d/
|
||||
install_file debian_buster.list /etc/apt/sources.list.d/
|
||||
|
||||
# Install Debian GPG keys
|
||||
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys DCC9EFBF77E11517
|
||||
@@ -29,8 +29,8 @@ install_chromium()
|
||||
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 112695A0E562B32A
|
||||
|
||||
# Install package manager conf file for Chromium
|
||||
installfile apt_chromium.conf /etc/apt/preferences.d/
|
||||
tagfile /etc/apt/preferences.d/apt_chromium.conf
|
||||
install_file apt_chromium.conf /etc/apt/preferences.d/
|
||||
tag_file /etc/apt/preferences.d/apt_chromium.conf
|
||||
|
||||
# Update package list and install
|
||||
prnt I "Mise à jour de la liste des dépots..."
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
# * MK_PORT: Port check_mk agent will use to communicate with server
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
export VER_install_mkagent="0.0.5"
|
||||
export VER_install_mkagent="0.0.6"
|
||||
export DEP_install_mkagent="upgrade_dist install_pkg"
|
||||
|
||||
install_mkagent()
|
||||
@@ -21,13 +21,13 @@ install_mkagent()
|
||||
pkginst xinetd /tmp/check-mk-agent_${MK_VERSION}_all.deb
|
||||
rm /tmp/check-mk-agent_${MK_VERSION}_all.deb
|
||||
|
||||
backupdist /etc/xinetd.d/check_mk
|
||||
installfile cmk/check_mk /etc/xinetd.d/check_mk
|
||||
tagfile /etc/xinetd.d/check_mk
|
||||
backup_dist /etc/xinetd.d/check_mk
|
||||
install_file cmk/check_mk /etc/xinetd.d/check_mk
|
||||
tag_file /etc/xinetd.d/check_mk
|
||||
sed -i -e "s/@MK_SERVER_IP@/$MK_SERVER_IP/" /etc/xinetd.d/check_mk
|
||||
|
||||
mkdir -pv /usr/lib/check_mk_agent/plugins/28800
|
||||
installfile cmk/mk_apt /usr/lib/check_mk_agent/plugins/28800/mk_apt
|
||||
install_file cmk/mk_apt /usr/lib/check_mk_agent/plugins/28800/mk_apt
|
||||
|
||||
svc_restart xinetd
|
||||
}
|
||||
@@ -46,7 +46,7 @@ precheck_install_mkagent()
|
||||
prnt E "Undeclared check_mk server."
|
||||
die 162
|
||||
fi
|
||||
file_exists cmk/check_mk cmk/mk_apt
|
||||
file_must_exists cmk/check_mk cmk/mk_apt
|
||||
}
|
||||
|
||||
export -f install_mkagent
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
# * PKGSEL: List of package to install
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
export VER_install_pkg="0.1.4"
|
||||
export VER_install_pkg="0.1.5"
|
||||
export DEP_install_pkg="upgrade_dist"
|
||||
|
||||
install_pkg()
|
||||
@@ -29,9 +29,9 @@ install_pkg()
|
||||
for pkg in $PKGS_BLACKLIST; do
|
||||
prnt I "Placing $pkg into the blacklist..."
|
||||
local dest=/etc/apt/preferences.d/blacklist_$pkg
|
||||
installfile pkgman/blacklist.conf $dest &&
|
||||
install_file pkgman/blacklist.conf $dest &&
|
||||
sed -i -e "s/@pkg@/pkg/" $dest
|
||||
tagfile $dest
|
||||
tag_file $dest
|
||||
|
||||
# If blacklisted we suppose uninstall as well (if neeeded)
|
||||
pkgrm $pkg
|
||||
@@ -59,6 +59,7 @@ precheck_install_pkg()
|
||||
|
||||
if [[ -z PKGS_BLACKLIST ]]; then
|
||||
prnt W "The packages $pkg will be placed into the blacklist !"
|
||||
file_must_exists pkgman/blacklist.conf
|
||||
fi
|
||||
|
||||
if [[ -z $PKGSEL ]]; then
|
||||
@@ -66,7 +67,6 @@ precheck_install_pkg()
|
||||
else
|
||||
prnt I "$(echo $PKGSEL | wc -w) additionnal package have to be installed."
|
||||
fi
|
||||
file_exists pkgman/blacklist.conf
|
||||
}
|
||||
|
||||
export -f install_pkg
|
||||
|
||||
@@ -8,12 +8,12 @@
|
||||
# https://opensource.org/licenses/BSD-3-Clause
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
export VER_install_profile="0.0.5"
|
||||
export VER_install_profile="0.0.6"
|
||||
export DEP_install_profile="install_pkg"
|
||||
|
||||
install_profile()
|
||||
{
|
||||
installfile profile/ansi_shadow.flf /usr/share/figlet/ansi_shadow.flf
|
||||
install_file profile/ansi_shadow.flf /usr/share/figlet/ansi_shadow.flf
|
||||
|
||||
local usrlist="/root"
|
||||
if find /home -mindepth 1 -maxdepth 1 -type d | read; then
|
||||
@@ -21,22 +21,22 @@ install_profile()
|
||||
fi
|
||||
|
||||
for usr in $usrlist; do
|
||||
backupdist $usr/{.,}profile $usr/.bashrc
|
||||
installfile profile/{{.,}profile,.bashrc} $usr/
|
||||
tagfile $usr/{{.,}profile,.bashrc}
|
||||
installfile profile/.tmux/.tmux.conf{,.local} $usr/
|
||||
tagfile $usr/.tmux.conf{,.local}
|
||||
backup_dist $usr/{.,}profile $usr/.bashrc
|
||||
install_file profile/{{.,}profile,.bashrc} $usr/
|
||||
tag_file $usr/{{.,}profile,.bashrc}
|
||||
install_file profile/.tmux/.tmux.conf{,.local} $usr/
|
||||
tag_file $usr/.tmux.conf{,.local}
|
||||
done
|
||||
unset usrlist
|
||||
|
||||
backupdist /etc/motd
|
||||
installfile profile/motd /etc/motd
|
||||
tagfile /etc/motd
|
||||
backup_dist /etc/motd
|
||||
install_file profile/motd /etc/motd
|
||||
tag_file /etc/motd
|
||||
}
|
||||
|
||||
precheck_install_profile()
|
||||
{
|
||||
file_exists profile/{{.,}profile,.bashrc,.tmux/.tmux.conf{,.local}}
|
||||
file_must_exists profile/{{.,}profile,.bashrc,.tmux/.tmux.conf{,.local}}
|
||||
}
|
||||
|
||||
export -f install_profile
|
||||
|
||||
@@ -8,22 +8,25 @@
|
||||
# https://opensource.org/licenses/BSD-3-Clause
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
export VER_patch_snmp="0.0.3"
|
||||
export VER_patch_snmp="0.1.0"
|
||||
export DEP_patch_snmp="install_pkg"
|
||||
|
||||
patch_snmp()
|
||||
{
|
||||
pkginst snmpd
|
||||
backupdist /etc/snmp/snmpd.conf /etc/default/snmpd \
|
||||
backup_dist /etc/snmp/snmpd.conf /etc/default/snmpd \
|
||||
/lib/systemd/system/snmpd.service /etc/init.d/snmpd
|
||||
installfile snmpd/snmpd.conf /etc/snmp/snmpd.conf
|
||||
install_file snmpd/snmpd.conf /etc/snmp/snmpd.conf
|
||||
tagfile /etc/snmp/snmpd.conf
|
||||
# No longer required with Debian >= 11 or Devuan >= 4
|
||||
# installfile snmpd/snmpd.init /etc/init.d/snmpd
|
||||
installfile snmpd/snmpd.default /etc/default/snmpd
|
||||
tagfile /etc/default/snmpd
|
||||
if [[ ($SYS_DIST == 'debian' && $SYS_VER -lt 11) ||
|
||||
($SYS_DIST == 'devuan' && $SYS_VER -lt 4) ]]; then
|
||||
install_file snmpd/snmpd.init /etc/init.d/snmpd
|
||||
fi
|
||||
install_file snmpd/snmpd.default /etc/default/snmpd
|
||||
tag_file /etc/default/snmpd
|
||||
if [[ -e /lib/systemd/system/snmpd.service ]]; then
|
||||
installfile snmpd/snmpd.service /lib/systemd/system/snmpd.service
|
||||
install_file snmpd/snmpd.service /lib/systemd/system/snmpd.service
|
||||
if command -v systemctl &> /dev/null; then
|
||||
systemctl daemon-reload
|
||||
fi
|
||||
@@ -33,9 +36,9 @@ patch_snmp()
|
||||
|
||||
precheck_patch_snmp()
|
||||
{
|
||||
file_exists snmpd/snmpd.{conf,default}
|
||||
file_must_exists snmpd/snmpd.{conf,default}
|
||||
if [[ -e /lib/systemd/system/snmpd.service ]]; then
|
||||
file_exists snmpd/snmpd.service
|
||||
file_must_exists snmpd/snmpd.service
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
# * PROXY_SRV_PORT: Working port for general purpose proxy if one declared
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
export VER_upgrade_dist="0.2.2"
|
||||
export VER_upgrade_dist="0.2.3"
|
||||
|
||||
# As aptitude might fail if clock is too far from real time, we need to depend
|
||||
# on ntp
|
||||
@@ -26,10 +26,10 @@ upgrade_dist()
|
||||
local proxyfile=/etc/apt/apt.conf.d/00proxy
|
||||
local norecommends=/etc/apt/apt.conf.d/99no-recommends
|
||||
|
||||
# We backup entire apt dir as future version will normalise source.list files
|
||||
backupdist /etc/apt
|
||||
# We backup entire apt dir
|
||||
backup_dist /etc/apt
|
||||
prnt I "Basic apt configuration..."
|
||||
tagfile $norecommend
|
||||
tag_file $norecommend
|
||||
echo 'APT::Install-Recommends "false";' >> $norecommends
|
||||
echo 'APT::AutoRemove::RecommendsImportant "false";' >> $norecommends
|
||||
echo 'APT::AutoRemove::SuggestsImportant "false";' >> $norecommends
|
||||
@@ -42,17 +42,17 @@ upgrade_dist()
|
||||
die 60
|
||||
)
|
||||
fi
|
||||
tagfile $proxyfile
|
||||
tag_file $proxyfile
|
||||
echo "Acquire::http::Proxy \"http://${PROXY_APT}:${PROXY_APT_PORT}\";" >> $proxyfile
|
||||
elif [[ -n $PROXY_SRV ]]; then
|
||||
tagfile $proxyfile
|
||||
tag_file $proxyfile
|
||||
echo "Acquire::http::Proxy \"http://${PROXY_SRV}:${PROXY_SRV_PORT}\";" >> $proxyfile
|
||||
else
|
||||
prnt I "No proxy configured, nothing to do."
|
||||
fi
|
||||
|
||||
# Remplace source.list from dist with ours (be smarter)
|
||||
installfile "pkgman/${SYS_DIST}_${SYS_VER}.list" /etc/apt/sources.list
|
||||
install_file "pkgman/${SYS_DIST}_${SYS_VER}.list" /etc/apt/sources.list
|
||||
|
||||
prnt I "Updating package list..."
|
||||
pkgupdt
|
||||
@@ -80,7 +80,7 @@ precheck_upgrade_dist()
|
||||
prnt E "A general proxy server have been specified but not its working port."
|
||||
die 160
|
||||
fi
|
||||
file_exists pkgman/${SYS_DIST}_${SYS_VER}.list
|
||||
file_must_exists pkgman/${SYS_DIST}_${SYS_VER}.list
|
||||
}
|
||||
|
||||
cron_upgrade_dist()
|
||||
|
||||
Reference in New Issue
Block a user