improved code quality, few bug fixes
This commit is contained in:
@@ -20,22 +20,22 @@
|
||||
# * DEFAULT_SHELL: The shell to use when creating new users
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
export VER_authnz=0.2.2
|
||||
export VER_authnz="0.2.2"
|
||||
export DEP_authnz="upgrade_dist"
|
||||
|
||||
# Users (from Ldap)
|
||||
add_remote_user()
|
||||
{
|
||||
if [[ $(grep "^$1:" /etc/passwd) ]]; then
|
||||
if [[ -n $(grep "^$1:" /etc/passwd) ]]; then
|
||||
prnt W "A local user with name $1 already exists, adding anyway!"
|
||||
fi
|
||||
if [[ $(grep "^+$1:" /etc/passwd) ]]; then
|
||||
if [[ -n $(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/shadow) ]]; then
|
||||
if [[ -n $(grep "^+$1:" /etc/shadow) ]]; then
|
||||
prnt W "The remote user $1 is already connectable, nothing to do in shadow."
|
||||
else
|
||||
echo "+$1::::::::" >> /etc/shadow
|
||||
@@ -46,10 +46,10 @@ add_remote_user()
|
||||
# Remove users
|
||||
remove_user()
|
||||
{
|
||||
if [[ $(grep "^$1:" /etc/{passwd,shadow,group,gshadow}) ]]; then
|
||||
if [[ -n $(grep "^$1:" /etc/{passwd,shadow,group,gshadow}) ]]; then
|
||||
# Using sed is more universal than any distro commands - local case
|
||||
sed -i -e "/^$1:/d" /etc/{passwd,shadow,group,gshadow}
|
||||
elif [[ $(grep "^+$1:" /etc/{passwd,shadow,group,gshadow}) ]]; then
|
||||
elif [[ -n $(grep "^+$1:" /etc/{passwd,shadow,group,gshadow}) ]]; then
|
||||
# remote case
|
||||
sed -i -e "/^+$1:/d" /etc/{passwd,shadow,group,gshadow}
|
||||
else
|
||||
|
||||
@@ -37,7 +37,7 @@ conf_ceph()
|
||||
pkginst ceph-common
|
||||
|
||||
# hosts files required for Ceph bootstrap when DNS not yet started
|
||||
if [[ ! $(grep "# Ceph" /etc/hosts) ]]; then
|
||||
if [[ -z $(grep "# Ceph" /etc/hosts) ]]; then
|
||||
prnt I "Adding server list to /etc/hosts"
|
||||
backup_dist /etc/hosts
|
||||
tag_file /etc/hosts
|
||||
@@ -57,7 +57,7 @@ conf_ceph()
|
||||
fstabchanged=true
|
||||
echo >> /etc/fstab
|
||||
local srvlist=$(echo $CEPH_SRV_NAMES | sed "s/ /,/g")
|
||||
if [[ ! $(grep $srvlist /etc/fstab) ]]; then
|
||||
if [[ -z $(grep $srvlist /etc/fstab) ]]; then
|
||||
echo "# Ceph :" >> /etc/fstab
|
||||
echo "$srvlist:/ /srv/ceph ceph defaults,_netdev,name=admin,secret=$CEPH_SECRET 0 0" >> /etc/fstab
|
||||
else
|
||||
@@ -72,7 +72,7 @@ conf_ceph()
|
||||
prnt I "Adding Samba entries to /etc/fstab"
|
||||
fstabchanged=true
|
||||
echo >> /etc/fstab
|
||||
if [[ ! $(grep $SMBSRV /etc/fstab) ]]; then
|
||||
if [[ -z $(grep $SMBSRV /etc/fstab) ]]; then
|
||||
echo "# Samba:" >> /etc/fstab
|
||||
echo "//$SMBSRV/share /srv/ceph/share cifs defaults,_netdev,username=root,password= 0 0" >> /etc/fstab
|
||||
else
|
||||
@@ -83,7 +83,7 @@ conf_ceph()
|
||||
prnt E "Ceph status not understood, the next tasks will probably fail"
|
||||
fi
|
||||
if [[ $success == yes ]]; then
|
||||
if [[ ! $(grep "^/srv/ceph/share" /etc/fstab) ]]; then
|
||||
if [[ -z $(grep "^/srv/ceph/share" /etc/fstab) ]]; then
|
||||
fstabchanged=true
|
||||
echo "/srv/ceph/share /share none defaults,_netdev,bind 0 0" >> /etc/fstab
|
||||
if [[ $SHARED_HOME == 1 ]]; then
|
||||
@@ -101,10 +101,10 @@ conf_ceph()
|
||||
|
||||
# Mount Ceph volumes if required
|
||||
prnt I "Mounting ceph volumes"
|
||||
[[ ! $(mount | grep "on /srv/ceph") ]] && mount -v /srv/ceph || mount -v /srv/ceph/share
|
||||
[[ ! $(mount | grep "on /share") ]] && mount -v /share
|
||||
[[ -z $(mount | grep "on /srv/ceph") ]] && mount -v /srv/ceph || mount -v /srv/ceph/share
|
||||
[[ -z $(mount | grep "on /share") ]] && mount -v /share
|
||||
if [[ $SHARED_HOME == "true" ]]; then
|
||||
[[ ! $(mount | grep "on /home") ]] && mount -v /home
|
||||
[[ -z $(mount | grep "on /home") ]] && mount -v /home
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ precheck_conf_disks()
|
||||
prnt E "Format de disque inconnu ($CALCTYPE) !"
|
||||
die 150
|
||||
fi
|
||||
|
||||
|
||||
prnt I "Vérification des lecteurs pour disque de calcul."
|
||||
local drvcount=0
|
||||
for drv in $CALCDRV; do
|
||||
@@ -105,7 +105,7 @@ precheck_conf_disks()
|
||||
prnt I "Le dique $drv est vierge, il sera formaté en $CALCTYPE."
|
||||
else
|
||||
prnt W "Le disque $drv n'est pas vierge !"
|
||||
if [[ $FORCEBLANK==true ]]; then
|
||||
if [[ $FORCEBLANK == true ]]; then
|
||||
prnt W "Le disque $drv sera réinitialisé !"
|
||||
else
|
||||
prnt E "La réinitialisation de $drv n'est pas autorisé, rien ne sera fait !"
|
||||
@@ -119,7 +119,7 @@ precheck_conf_disks()
|
||||
(( drvcount+=1 ))
|
||||
done
|
||||
|
||||
if [[ ! $CALCTYPE=="zfs" && drvcount -gt 1 ]]; then
|
||||
if [[ ! $CALCTYPE == "zfs" && drvcount -gt 1 ]]; then
|
||||
prnt E "Plusieurs diques impossibles avec Ext4 ou XFS !"
|
||||
die 150
|
||||
fi
|
||||
|
||||
@@ -31,7 +31,7 @@ conf_locale()
|
||||
|
||||
# Removing locales not in the list
|
||||
prnt I "Deactivating initial locales from installation..."
|
||||
if [[ $(grep -v '^#' $gen_fname | grep -v -e '^[[:space:]]*$') ]]; then
|
||||
if [[ -n $(grep -v '^#' $gen_fname | grep -v -e '^[[:space:]]*$') ]]; then
|
||||
grep -v '^#' $gen_fname | grep -v -e '^[[:space:]]*$' |
|
||||
while read -r line; do
|
||||
sed -i "s/$line/# $line/" $gen_fname
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
# * MAIL_RELAY: Name of the mail relay server
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
export VER_conf_mail="0.0.7"
|
||||
export VER_conf_mail="0.0.8"
|
||||
export DEP_conf_mail="upgrade_dist"
|
||||
|
||||
conf_mail()
|
||||
@@ -30,7 +30,7 @@ conf_mail()
|
||||
-e "s/@MAIL_RELAY@/$MAIL_RELAY/" $pfmain
|
||||
|
||||
echo $HOSTNAME.$REALM > /etc/mailname
|
||||
tag_file /etc/mailname
|
||||
#tag_file /etc/mailname
|
||||
|
||||
svc_restart postfix
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ conf_network()
|
||||
ifup -a || true && prnt W "Ignoring errors here."
|
||||
|
||||
unset iface if_file
|
||||
NEED_REBOOT=true
|
||||
export NEED_REBOOT=true
|
||||
}
|
||||
|
||||
precheck_conf_network()
|
||||
@@ -117,7 +117,7 @@ precheck_conf_network()
|
||||
if [[ ! -d /sys/class/net/$iface ]]; then
|
||||
prnt E "The iface $iface, asked to configure, do not exist!"
|
||||
die 175
|
||||
else
|
||||
else
|
||||
if [[ $(grep "up" /sys/class/net/$iface/operstate) ]]; then
|
||||
prnt W "The IPv4 iface $iface, is already configured, a reboot will be required."
|
||||
fi
|
||||
|
||||
@@ -24,16 +24,16 @@ conf_nfs()
|
||||
pkginst nfs-common
|
||||
for mnt in $NFS_MOUNTS; do
|
||||
local mnt_serv=${!MOUNTSERV_$mnt}
|
||||
local mnt_point=${!MOUNTPOINT_$mnt}
|
||||
local mnt_point="${!MOUNTPOINT_$mnt}"
|
||||
local mnt_opts=${!MOUNTOPTS_$mnt:-"defaults,_netdev"}
|
||||
if [[ ! $(grep "$mnt_serv" /etc/fstab) ]]; then
|
||||
echo -e "${mnt_serv}\t${mnt_point}\tnfs4\tdefaults,_netdev\t0\t0" >> /etc/fstab
|
||||
if [[ -z $(grep "$mnt_serv" /etc/fstab) ]]; then
|
||||
echo -e "${mnt_serv}\t${mnt_point}\tnfs4\t${mnt_opts}\t0\t0" >> /etc/fstab
|
||||
fi
|
||||
unset mnt_serv
|
||||
if [[ ! -d $mnt_point ]]; then
|
||||
mkdir -pv $mnt_point
|
||||
mkdir -pv "$mnt_point"
|
||||
fi
|
||||
mount $mnt_point
|
||||
mount "$mnt_point"
|
||||
unset mnt_point
|
||||
done
|
||||
}
|
||||
|
||||
@@ -38,15 +38,15 @@ conf_ntp()
|
||||
|
||||
prnt I "Installing NTP configuration file..."
|
||||
local dest="${conf_file}.work"
|
||||
backup_dist $conf_file
|
||||
install_file ntp.conf $dest
|
||||
tag_file $dest
|
||||
backup_dist "$conf_file"
|
||||
install_file ntp.conf "$dest"
|
||||
tag_file "$dest"
|
||||
local line=""
|
||||
for srv in $NTP_SERVERS; do
|
||||
line="${line}server $srv iburst\n"
|
||||
done
|
||||
sed -i -e "s/@SERVERLIST@/$line/" $dest &&
|
||||
mv -fv $dest $conf_file
|
||||
sed -i -e "s/@SERVERLIST@/$line/" "$dest" &&
|
||||
mv -fv "$dest" "$conf_file"
|
||||
|
||||
prnt I "Starting service ntp..."
|
||||
|
||||
|
||||
@@ -32,13 +32,17 @@ install_chromium()
|
||||
prnt I "Adding Debian Bullseye repository to software sources..."
|
||||
install_file debian_bullseye.list /etc/apt/sources.list.d/
|
||||
;;
|
||||
22.04|22.10|23.04|23.10)
|
||||
prnt I "Adding Debian Bookworm repository to software sources..."
|
||||
install_file debian_bookworm.list /etc/apt/sources.list.d/
|
||||
;;
|
||||
esac
|
||||
|
||||
# Install Debian GPG keys
|
||||
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys DCC9EFBF77E11517
|
||||
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 648ACFD622F3D138
|
||||
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys AA8E81B4331F7F50
|
||||
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 112695A0E562B32A
|
||||
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys "DCC9EFBF77E11517"
|
||||
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys "648ACFD622F3D138"
|
||||
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys "AA8E81B4331F7F50"
|
||||
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys "112695A0E562B32A"
|
||||
|
||||
# Install package manager conf file for Chromium
|
||||
install_file apt_chromium.conf /etc/apt/preferences.d/
|
||||
@@ -69,6 +73,9 @@ precheck_install_chromium()
|
||||
20.04|20.10|21.04|21.10)
|
||||
prnt m " * Detected Ubuntu $SYS_VER, will install Bullseye version of Chromium"
|
||||
;;
|
||||
22.04|22.10|23.04|23.10)
|
||||
prnt m " * Detected Ubuntu $SYS_VER, will install Bookworm version of Chromium"
|
||||
;;
|
||||
*)
|
||||
prnt E "Unable to determine the corresponding Debian version."
|
||||
die 165
|
||||
|
||||
@@ -24,12 +24,12 @@ install_desktop()
|
||||
prnt I "Installing additionnal X11 drivers..."
|
||||
pkginst $X11_DRV
|
||||
fi
|
||||
if [[ $UBUNTU_FLAVOR ]]; then
|
||||
if [[ -n $UBUNTU_FLAVOR ]]; then
|
||||
prnt I "Installing $UBUNTU_FLAVOR environment..."
|
||||
pkginst ${UBUNTU_FLAVOR}-desktop
|
||||
fi
|
||||
# Because we're lazy but manual actions can avoid reboot...
|
||||
NEED_REBOOT=true
|
||||
export NEED_REBOOT=true
|
||||
}
|
||||
|
||||
precheck_install_desktop()
|
||||
|
||||
@@ -25,7 +25,7 @@ install_pkg()
|
||||
fi
|
||||
|
||||
# Blacklist some anoying packages (and remove them if needed)
|
||||
if [[ -n PKGS_BLACKLIST ]]; then
|
||||
if [[ -n $PKGS_BLACKLIST ]]; then
|
||||
for pkg in $PKGS_BLACKLIST; do
|
||||
prnt I "Placing $pkg into the blacklist..."
|
||||
local dest=/etc/apt/preferences.d/blacklist_$pkg
|
||||
@@ -51,13 +51,13 @@ install_pkg()
|
||||
|
||||
precheck_install_pkg()
|
||||
{
|
||||
if [[ -z PKGS_RMLIST ]]; then
|
||||
if [[ -z $PKGS_RMLIST ]]; then
|
||||
prnt m " * No package to remove."
|
||||
else
|
||||
prnt m " * $(echo $PKGS_RMLIST | wc -w) package to remove."
|
||||
fi
|
||||
|
||||
if [[ -z PKGS_BLACKLIST ]]; then
|
||||
if [[ -z $PKGS_BLACKLIST ]]; then
|
||||
prnt m " * The packages $pkg will be placed into the blacklist !"
|
||||
file_must_exists pkgman/blacklist.conf
|
||||
else
|
||||
|
||||
@@ -30,7 +30,7 @@ install_profile()
|
||||
#tag_file $usr/.tmux.conf{,.local}
|
||||
if [[ ! -d $usr/profile ]]; then
|
||||
(
|
||||
cd $usr
|
||||
cd $usr || return 205
|
||||
git config --global http.sslverify false
|
||||
git clone https://git.geoffray-levasseur.org/fatalerrors/profile.git
|
||||
git config --global http.sslverify true
|
||||
|
||||
@@ -20,7 +20,7 @@ select_system_proxy()
|
||||
else
|
||||
prnt I "No proxy configuration set, nothing to do."
|
||||
fi
|
||||
NEED_REBOOT=true
|
||||
export NEED_REBOOT=true
|
||||
}
|
||||
|
||||
precheck_select_system_proxy()
|
||||
|
||||
@@ -29,10 +29,12 @@ upgrade_dist()
|
||||
# We backup entire apt dir
|
||||
backup_dist /etc/apt
|
||||
prnt I "Basic apt configuration..."
|
||||
tag_file $norecommend
|
||||
echo 'APT::Install-Recommends "false";' >> $norecommends
|
||||
echo 'APT::AutoRemove::RecommendsImportant "false";' >> $norecommends
|
||||
echo 'APT::AutoRemove::SuggestsImportant "false";' >> $norecommends
|
||||
tag_file $norecommends
|
||||
{
|
||||
echo 'APT::Install-Recommends "false";'
|
||||
echo 'APT::AutoRemove::RecommendsImportant "false";'
|
||||
echo 'APT::AutoRemove::SuggestsImportant "false";'
|
||||
} >> $norecommends
|
||||
|
||||
prnt I "Configuring proxy for APT..."
|
||||
if [[ -n $PROXY_APT ]]; then
|
||||
|
||||
Reference in New Issue
Block a user