Compare commits

...

6 Commits

29 changed files with 167 additions and 149 deletions

View File

@@ -19,12 +19,12 @@ export REMOVE_USERS="fatal"
export NTP_SERVERS="didicas.$REALM cagua.$REALM" export NTP_SERVERS="didicas.$REALM cagua.$REALM"
# Ceph share # Ceph share
export CEPH_SRV_NAMES="mayon pinatubo ragang taal jolo" export CEPH_SRV_NAMES="mayon pinatubo ragang taal"
export CEPHIP_mayon="192.168.1.254" export CEPHIP_mayon="192.168.1.254"
export CEPHIP_pinatubo="192.168.1.253" export CEPHIP_pinatubo="192.168.1.253"
export CEPHIP_ragang="192.168.1.252" export CEPHIP_ragang="192.168.1.252"
export CEPHIP_taal="192.168.1.251" export CEPHIP_taal="192.168.1.251"
export CEPHIP_jolo="192.168.1.30" #export CEPHIP_jolo="192.168.1.30"
export CEPH_SECRET="AQAxSf5c2A/CMxAAnOu1RrSf7Yr2h60CLttq4g==" export CEPH_SECRET="AQAxSf5c2A/CMxAAnOu1RrSf7Yr2h60CLttq4g=="
export SHARED_HOME="false" export SHARED_HOME="false"

View File

@@ -13,7 +13,7 @@ export PKGS_BASE="debconf-utils debhelper deborphan ethtool cpufrequtils \
sysbench sysstat ifstat iftop iotop mtr-tiny tcpdump mc pbzip2 pigz \ sysbench sysstat ifstat iftop iotop mtr-tiny tcpdump mc pbzip2 pigz \
xz-utils zip unzip plzip lzip ftp lftp bc dc dos2unix psmisc udunits-bin \ xz-utils zip unzip plzip lzip ftp lftp bc dc dos2unix psmisc udunits-bin \
whois tmux screen debconf-doc dump figlet gawk gpm multitail neofetch nmap \ whois tmux screen debconf-doc dump figlet gawk gpm multitail neofetch nmap \
oping pv whois traceroute rsync tree git qemu-guest-agent" oping pv traceroute rsync tree git qemu-guest-agent"
# Agregation of the package lists # Agregation of the package lists
export PKGSEL="$PKGS_BASE" export PKGSEL="$PKGS_BASE"

View File

@@ -1,3 +1,4 @@
#!/bin/bash
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Error management functions # Error management functions
# This file is part of the init.sh project # This file is part of the init.sh project
@@ -29,7 +30,7 @@ function die()
unset errorcode unset errorcode
# Put the trigger back (only executed with --keepgoing) # Put the trigger back (only executed with --keepgoing)
trap "error ${LINENO}" ERR trap 'error ${LINENO}' ERR
} }
export -f die export -f die
@@ -73,8 +74,8 @@ trap "error ${LINENO}; backtrace; err_exit" ERR
function err_exit function err_exit
{ {
if [[ $KEEPGOING != true ]]; then if [[ $KEEPGOING != true ]]; then
if [[ -f $tmpfile ]]; then if [[ -f "$tmpfile" ]]; then
rm -f $tmpfile rm -f "$tmpfile"
fi fi
exit 255 exit 255
fi fi
@@ -94,7 +95,7 @@ function backtrace
printf '%15s() %s:%d\n' \ printf '%15s() %s:%d\n' \
"$func" "${BASH_SOURCE[$i]}" "${BASH_LINENO[ (( $i - 1)) ]}" "$func" "${BASH_SOURCE[$i]}" "${BASH_LINENO[ (( $i - 1)) ]}"
fi fi
let i++ || true (( i++ )) || true
done done
unset func i unset func i
echo "==============================" echo "=============================="
@@ -120,7 +121,7 @@ noerror()
fi fi
echo $? echo $?
trap "error ${LINENO}" ERR trap 'error ${LINENO}' ERR
set -o errexit set -o errexit
} }
export -f noerror export -f noerror

View File

@@ -1,3 +1,4 @@
#!/bin/bash
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Chroot system functions # Chroot system functions
# This file is part of the init.sh project # This file is part of the init.sh project
@@ -13,36 +14,36 @@
# If chrooted, we need to bootstrap to a new copy of our directory tree # If chrooted, we need to bootstrap to a new copy of our directory tree
chroot_bootstrap() chroot_bootstrap()
{ {
if [[ ! -d $CHROOT_PATH ]]; then if [[ ! -d "$CHROOT_PATH" ]]; then
prnt E "The path given to chroot don't exists." prnt E "The path given to chroot don't exists."
die 14 die 14
fi fi
if [[ ! -d $CHROOT_PATH/tmp ]]; then if [[ ! -d "$CHROOT_PATH/tmp" ]]; then
prnt E "The target filesystem doesn't seems to be a valid installation." prnt E "The target filesystem doesn't seems to be a valid installation."
die 15 die 15
fi fi
local tmpdir=$(mktemp -d $CHROOT_PATH/tmp/init.sh-XXXX) local tmpdir=$(mktemp -d "$CHROOT_PATH/tmp/init.sh-XXXX")
local bootstrap_items="conf lib modules repo bash.rc init.sh prepost.d" local bootstrap_items="conf lib modules repo bash.rc init.sh prepost.d"
if [[ $RESUME == true ]]; then if [[ $RESUME == true ]]; then
bootstrap_items="$bootstrap_items $STAGE_FILE" bootstrap_items="$bootstrap_items $STAGE_FILE"
fi fi
prnt I "Preparing root change." prnt I "Preparing root change."
cp -av $bootstrap_items $tmpdir cp -av $bootstrap_items "$tmpdir"
prnt I "Changing root and starting a fork of init.sh..." prnt I "Changing root and starting a fork of init.sh..."
# on the following line, true allows to correctly exit in case of error since # on the following line, true allows to correctly exit in case of error since
# errors are managed by the chrooted environment # errors are managed by the chrooted environment
chroot $CHROOT_PATH /bin/bash -c 'CHROOT_DONE=true; $tmpdir/init.sh $@' || true chroot "$CHROOT_PATH" /bin/bash -c 'CHROOT_DONE=true; "$tmpdir/init.sh" "$@"' || true
# If stage file still exists we copy it to be able to resume later # If stage file still exists we copy it to be able to resume later
if [[ -e $tmpdir/$(basename $STAGE_FILE) ]]; then if [[ -e "$tmpdir/$(basename "$STAGE_FILE")" ]]; then
cp $tmpdir/$(basename $STAGE_FILE) $STAGE_FILE cp "$tmpdir/$(basename "$STAGE_FILE")" "$STAGE_FILE"
fi fi
prnt I "Back to host system and clean up." prnt I "Back to host system and clean up."
rm -rf $tmpdir rm -rf "$tmpdir"
} }
# EOF # EOF

View File

@@ -1,3 +1,4 @@
#!/bin/env bash
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Main program functions # Main program functions
# This file is part of the init.sh project # This file is part of the init.sh project
@@ -14,39 +15,46 @@
# errors with immediate exit. # errors with immediate exit.
read_commandline() read_commandline()
{ {
syntax_error()
{
prnt E "Error while analysing command line parameters."
die 1 --force
}
# Processing command line options # Processing command line options
local want_module=false
local want_logfile=false
local want_conffile=false
local want_chroot=false
local opt= local opt=
for opt in $@; do local params=''
case $opt in params=$(getopt -n init.sh -o hvm:cjkrRDoPl:f:s \
--long help,version,module:,check-only,jump,keep-going,resume,no-root-check,no-deps,offline,no-proxy,logfile:,file:,shell,chroot,cron \
-- "$@")
eval set -- "$params"
while true; do
case $1 in
"-h"|"--help") "-h"|"--help")
disp_help disp_help
shift
exit 0 exit 0
;; ;;
"-v"|"--version") "-v"|"--version")
show_version show_version
shift
exit 0 exit 0
;; ;;
"-m"|"--module") "-m"|"--module")
local want_module=true if [[ -z $MANUAL_MODULE_LIST ]]; then
export MANUAL_MODULE_LIST=$2
else
prnt E "A module list have already been given!"
prnt E "Commande line only tolerate one --module parameter."
die 1 --force
fi
shift 2
;; ;;
"-c"|"--check-only") "-c"|"--check-only")
export CHECK_ONLY=true export CHECK_ONLY=true
shift
;; ;;
"-j"|"--jump") "-j"|"--jump")
export JUMP=true export JUMP=true
shift
;; ;;
"-k"|"--keep-going") "-k"|"--keep-going")
export KEEPGOING=true export KEEPGOING=true
shift
;; ;;
"-r"|"--resume") "-r"|"--resume")
if [[ -s $STAGE_FILE ]]; then if [[ -s $STAGE_FILE ]]; then
@@ -56,91 +64,68 @@ read_commandline()
prnt E "Without it, resuming is impossible." prnt E "Without it, resuming is impossible."
die 17 --force die 17 --force
fi fi
shift
;; ;;
"-R"|"--no-root-check") "-R"|"--no-root-check")
export NO_ROOT_CHECK=true export NO_ROOT_CHECK=true
shift
;; ;;
"-D"|"--no-deps") "-D"|"--no-deps")
export NO_DEPS=true export NO_DEPS=true
shift
;; ;;
"-o"|"--offline") "-o"|"--offline")
export OFFLINE=true export OFFLINE=true
shift
;; ;;
"-P"|"--no-proxy") "-P"|"--no-proxy")
export NO_PROXY=true export NO_PROXY=true
shift
;; ;;
"-l"|"--logfile") "-l"|"--logfile")
local want_logfile=true
;;
"-f"|"--file")
local want_conffile=true
;;
"-s"|"--shell")
export RUN_SHELL=true
;;
"--chroot")
local want_chroot=true
;;
"--cron")
export CRON_MODE=true
;;
*)
if [[ $want_module == true ]]; then
[[ $want_logfile == true ]] && synthax_error
[[ $want_conffile == true ]] && synthax_error
[[ $want_chroot == true ]] && synthax_error
if [[ -z $MANUAL_MODULE_LIST ]]; then
export MANUAL_MODULE_LIST=$opt
want_module=false
else
prnt E "A module list have already been given!"
prnt E "Commande line only tolerate one --module parameter."
die 1 --force
fi
elif [[ $want_logfile == true ]]; then
[[ $want_module == true ]] && synthax_error
[[ $want_conffile == true ]] && synthax_error
[[ $want_chroot == true ]] && synthax_error
if [[ -z $NEW_LOGFILE ]]; then if [[ -z $NEW_LOGFILE ]]; then
export NEW_LOGFILE=$opt export NEW_LOGFILE=$2
want_logfile=false
else else
prnt E "Impossible to specify several log files." prnt E "Impossible to specify several log files."
die 1 --force die 1 --force
fi fi
elif [[ $want_conffile == true ]]; then shift 2
[[ $want_module == true ]] && synthax_error ;;
[[ $want_logfile == true ]] && synthax_error "-f"|"--file")
[[ $want_chroot == true ]] && synthax_error
export CONFFILES="$CONFFILES $opt" export CONFFILES="$CONFFILES $opt"
want_logfile=false shift 2
elif [[ $want_chroot == true ]]; then ;;
[[ $want_module == true ]] && synthax_error "-s"|"--shell")
[[ $want_logfile == true ]] && synthax_error export RUN_SHELL=true
[[ $want_conffile == true ]] && synthax_error shift
;;
"--chroot")
if [[ -z $CHROOT_PATH ]]; then if [[ -z $CHROOT_PATH ]]; then
export CHROOT_PATH=$opt export CHROOT_PATH=$2
want_chroot=false
else else
prnt E "A chroot path have already been given." prnt E "A chroot path have already been given."
die 1 --force die 1 --force
fi fi
else shift 2
prnt E "Unknow parameter \"$opt\"." ;;
die 1 --force "--cron")
export CRON_MODE=true
shift
;;
--)
shift
break
;;
*)
if [[ -n $1 ]]; then
prnt E "Unknow parameter \"$1\" !"
die 1
fi fi
break
;; ;;
esac esac
done done
unset opt unset opt
# If those var are true at that point, something is wrong
if [[ $want_logfile == true ]] || [[ $want_module == true ]] ||
[[ $want_conffile == true ]] || [[ $want_chroot == true ]]; then
syntax_error
fi
unset want_conffile want_logfile want_module want_chroot
} }
export -f read_commandline export -f read_commandline
@@ -180,11 +165,12 @@ process_commandline_and_vars()
# Configure module list # Configure module list
if [[ -n $MANUAL_MODULE_LIST ]]; then if [[ -n $MANUAL_MODULE_LIST ]]; then
prnt W "A manual module list will be used." prnt W "A manual module list will be used:"
export MODULE_LIST=$(echo $MANUAL_MODULE_LIST | sed "s/,/ /g") export MODULE_LIST=${MANUAL_MODULE_LIST//,/ /g}
prnt m " * $MODULE_LIST"
fi fi
# Check for module list existance and basic syntax # Check for module list exis<tance and basic syntax
if [[ -n $MODULE_LIST ]]; then if [[ -n $MODULE_LIST ]]; then
for mod in $MODULE_LIST; do for mod in $MODULE_LIST; do
if [[ $mod =~ ['-!@#$%\&*=+'] ]]; then if [[ $mod =~ ['-!@#$%\&*=+'] ]]; then

View File

@@ -1,3 +1,4 @@
#!/bin/bash
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Disks and partitions manipulation function # Disks and partitions manipulation function
# This file is part of the init.sh project # This file is part of the init.sh project
@@ -82,7 +83,7 @@ mkparts()
local tmpfile=$(mktemp sfd.XXXX) local tmpfile=$(mktemp sfd.XXXX)
if [[ -n $1 ]]; then if [[ -n $1 ]]; then
# For each given size we make a partition # For each given size we make a partition
for $part in $@; do for part in $@; do
# If size is zero we interpret it as all available space # If size is zero we interpret it as all available space
if [[ $part == 0 ]]; then if [[ $part == 0 ]]; then
echo ",,L" >> $tmpfile echo ",,L" >> $tmpfile

View File

@@ -1,3 +1,4 @@
#!/bin/bash
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Some display functions and defines color codes # Some display functions and defines color codes
# This file is part of the init.sh project # This file is part of the init.sh project

View File

@@ -1,3 +1,4 @@
#!/bin/bash
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# File manipulation function # File manipulation function
# This file is part of the init.sh project # This file is part of the init.sh project
@@ -34,7 +35,7 @@ backup_dist()
if [[ -L ${file} ]]; then if [[ -L ${file} ]]; then
# With symbolik links we call again backup_dist to treat target # With symbolik links we call again backup_dist to treat target
prnt I "Following the symbolic link $file to do a proper backup..." prnt I "Following the symbolic link $file to do a proper backup..."
backup_dist $(readlink -f ${file}) backup_dist $(readlink -f "${file}")
elif [[ -f ${file} ]]; then elif [[ -f ${file} ]]; then
prnt I "Creating a backup of ${file} on $tmstmp..." prnt I "Creating a backup of ${file} on $tmstmp..."
cp -av $file ${file}.dist.${tmstmp} cp -av $file ${file}.dist.${tmstmp}
@@ -134,7 +135,7 @@ install_file()
prnt E "install_file(): At least two arguments are required." prnt E "install_file(): At least two arguments are required."
die 11 die 11
fi fi
if [[ $(echo $@ | grep "\*\|\?") ]]; then if [[ -n $(echo $@ | grep "\*\|\?") ]]; then
prnt E "install_file(): Wildcards are not authorized." prnt E "install_file(): Wildcards are not authorized."
die 7 die 7
fi fi
@@ -215,7 +216,7 @@ is_dir_empty()
return 0 return 0
fi fi
nbfiles=$(ls -a1 $dir | egrep -v '^.$|^..$' | wc -l) nbfiles=$(ls -a1 $dir | grep -Evc '^.$|^..$')
if [[ $nbfiles -eq 0 ]]; then if [[ $nbfiles -eq 0 ]]; then
return 0 return 0
fi fi
@@ -240,7 +241,7 @@ patch_file()
# Create a sub-process, to avoid bash environment pollution # Create a sub-process, to avoid bash environment pollution
( (
local varlist= pattern= local varlist='' pattern=''
if [[ $# -eq 0 ]] ; then if [[ $# -eq 0 ]] ; then
pattern="-e s/<\(.*\)>/\$\1\$\1/g" pattern="-e s/<\(.*\)>/\$\1\$\1/g"
else else
@@ -249,7 +250,6 @@ patch_file()
if ! declare -p $var >/dev/null 2>&1 ; then if ! declare -p $var >/dev/null 2>&1 ; then
local $var=$(eval echo \$$var) local $var=$(eval echo \$$var)
fi fi
export $var
pattern="$pattern -e s/@$var@/\$$var/g" pattern="$pattern -e s/@$var@/\$$var/g"
varlist=$varlist\$$var varlist=$varlist\$$var
done done

View File

@@ -1,3 +1,4 @@
#!/bin/bash
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Loaders for conf and prepost functions # Loaders for conf and prepost functions
# This file is part of the init.sh project # This file is part of the init.sh project

View File

@@ -1,3 +1,4 @@
#!/bin/bash
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Network functions # Network functions
# This file is part of the init.sh project # This file is part of the init.sh project

View File

@@ -1,3 +1,4 @@
#!/bin/bash
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Package manager integration # Package manager integration
# This file is part of the init.sh project # This file is part of the init.sh project

View File

@@ -1,3 +1,4 @@
#!/bin/bash
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Services manipulation functions # Services manipulation functions
# This file is part of the init.sh project # This file is part of the init.sh project

View File

@@ -1,3 +1,4 @@
#!/bin/bash
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Base support function # Base support function
# This file is part of the init.sh project # This file is part of the init.sh project

View File

@@ -1,3 +1,4 @@
#!/bin/bash
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Various utilitary functions # Various utilitary functions
# This file is part of the init.sh project # This file is part of the init.sh project
@@ -25,7 +26,7 @@ function_exists() {
die 11 --force die 11 --force
fi fi
if [[ $(LC_ALL=C type -t $1 | grep function) ]]; then if [[ -n $(LC_ALL=C type -t $1 | grep function) ]]; then
return 0 return 0
else else
return 1 return 1
@@ -42,7 +43,7 @@ get_mod_name()
prnt E "get_mod_name(): Bad number of parameters." prnt E "get_mod_name(): Bad number of parameters."
die 11 --force die 11 --force
fi fi
echo $(basename $1 | cut -f 1 -d '.') basename $1 | cut -f 1 -d '.'
} }
export -f get_mod_name export -f get_mod_name
@@ -52,7 +53,7 @@ export -f get_mod_name
trim() trim()
{ {
local string="$@" local string="$@"
echo "$(sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//'<<<"${string}")" sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//'<<<"${string}"
unset string unset string
} }
export -f trim export -f trim

View File

@@ -1,3 +1,4 @@
#!/bin/bash
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Version determination function # Version determination function
# This file is part of the init.sh project # This file is part of the init.sh project
@@ -37,7 +38,7 @@ get_os_version()
unset maj min unset maj min
fi fi
# Return values on stdout # Return values on stdout (awk used to retreave primary codename when using testing or unstable)
echo ${ID,,} ${VERSION_ID} $(echo ${VERSION_CODENAME,,} | awk '{print $1}') echo ${ID,,} ${VERSION_ID} $(echo ${VERSION_CODENAME,,} | awk '{print $1}')

View File

@@ -20,22 +20,22 @@
# * DEFAULT_SHELL: The shell to use when creating new users # * 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" export DEP_authnz="upgrade_dist"
# Users (from Ldap) # Users (from Ldap)
add_remote_user() 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!" prnt W "A local user with name $1 already exists, adding anyway!"
fi 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." prnt W "The remote user $1 is already declared, nothing to do in passwd."
else else
echo "+$1::::::" >> /etc/passwd echo "+$1::::::" >> /etc/passwd
prnt I "User $1 added to passwd..." prnt I "User $1 added to passwd..."
fi 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." prnt W "The remote user $1 is already connectable, nothing to do in shadow."
else else
echo "+$1::::::::" >> /etc/shadow echo "+$1::::::::" >> /etc/shadow
@@ -46,10 +46,10 @@ add_remote_user()
# Remove users # Remove users
remove_user() 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 # Using sed is more universal than any distro commands - local case
sed -i -e "/^$1:/d" /etc/{passwd,shadow,group,gshadow} 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 # remote case
sed -i -e "/^+$1:/d" /etc/{passwd,shadow,group,gshadow} sed -i -e "/^+$1:/d" /etc/{passwd,shadow,group,gshadow}
else else

View File

@@ -37,7 +37,7 @@ conf_ceph()
pkginst ceph-common pkginst ceph-common
# hosts files required for Ceph bootstrap when DNS not yet started # 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" prnt I "Adding server list to /etc/hosts"
backup_dist /etc/hosts backup_dist /etc/hosts
tag_file /etc/hosts tag_file /etc/hosts
@@ -57,7 +57,7 @@ conf_ceph()
fstabchanged=true fstabchanged=true
echo >> /etc/fstab echo >> /etc/fstab
local srvlist=$(echo $CEPH_SRV_NAMES | sed "s/ /,/g") 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 "# Ceph :" >> /etc/fstab
echo "$srvlist:/ /srv/ceph ceph defaults,_netdev,name=admin,secret=$CEPH_SECRET 0 0" >> /etc/fstab echo "$srvlist:/ /srv/ceph ceph defaults,_netdev,name=admin,secret=$CEPH_SECRET 0 0" >> /etc/fstab
else else
@@ -72,7 +72,7 @@ conf_ceph()
prnt I "Adding Samba entries to /etc/fstab" prnt I "Adding Samba entries to /etc/fstab"
fstabchanged=true fstabchanged=true
echo >> /etc/fstab echo >> /etc/fstab
if [[ ! $(grep $SMBSRV /etc/fstab) ]]; then if [[ -z $(grep $SMBSRV /etc/fstab) ]]; then
echo "# Samba:" >> /etc/fstab echo "# Samba:" >> /etc/fstab
echo "//$SMBSRV/share /srv/ceph/share cifs defaults,_netdev,username=root,password= 0 0" >> /etc/fstab echo "//$SMBSRV/share /srv/ceph/share cifs defaults,_netdev,username=root,password= 0 0" >> /etc/fstab
else else
@@ -83,7 +83,7 @@ conf_ceph()
prnt E "Ceph status not understood, the next tasks will probably fail" prnt E "Ceph status not understood, the next tasks will probably fail"
fi fi
if [[ $success == yes ]]; then if [[ $success == yes ]]; then
if [[ ! $(grep "^/srv/ceph/share" /etc/fstab) ]]; then if [[ -z $(grep "^/srv/ceph/share" /etc/fstab) ]]; then
fstabchanged=true fstabchanged=true
echo "/srv/ceph/share /share none defaults,_netdev,bind 0 0" >> /etc/fstab echo "/srv/ceph/share /share none defaults,_netdev,bind 0 0" >> /etc/fstab
if [[ $SHARED_HOME == 1 ]]; then if [[ $SHARED_HOME == 1 ]]; then
@@ -101,10 +101,10 @@ conf_ceph()
# Mount Ceph volumes if required # Mount Ceph volumes if required
prnt I "Mounting ceph volumes" prnt I "Mounting ceph volumes"
[[ ! $(mount | grep "on /srv/ceph") ]] && mount -v /srv/ceph || mount -v /srv/ceph/share [[ -z $(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 /share") ]] && mount -v /share
if [[ $SHARED_HOME == "true" ]]; then if [[ $SHARED_HOME == "true" ]]; then
[[ ! $(mount | grep "on /home") ]] && mount -v /home [[ -z $(mount | grep "on /home") ]] && mount -v /home
fi fi
} }

View File

@@ -31,7 +31,7 @@ conf_locale()
# Removing locales not in the list # Removing locales not in the list
prnt I "Deactivating initial locales from installation..." 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:]]*$' | grep -v '^#' $gen_fname | grep -v -e '^[[:space:]]*$' |
while read -r line; do while read -r line; do
sed -i "s/$line/# $line/" $gen_fname sed -i "s/$line/# $line/" $gen_fname

View File

@@ -13,7 +13,7 @@
# * MAIL_RELAY: Name of the mail relay server # * 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" export DEP_conf_mail="upgrade_dist"
conf_mail() conf_mail()
@@ -30,7 +30,7 @@ conf_mail()
-e "s/@MAIL_RELAY@/$MAIL_RELAY/" $pfmain -e "s/@MAIL_RELAY@/$MAIL_RELAY/" $pfmain
echo $HOSTNAME.$REALM > /etc/mailname echo $HOSTNAME.$REALM > /etc/mailname
tag_file /etc/mailname #tag_file /etc/mailname
svc_restart postfix svc_restart postfix
} }

View File

@@ -104,7 +104,7 @@ conf_network()
ifup -a || true && prnt W "Ignoring errors here." ifup -a || true && prnt W "Ignoring errors here."
unset iface if_file unset iface if_file
NEED_REBOOT=true export NEED_REBOOT=true
} }
precheck_conf_network() precheck_conf_network()

View File

@@ -1,28 +1,40 @@
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Description of module conf_nfs # Configure NFS mounts
# Copyright (c) Year Your Name <your.mail@host.tld> # This file is part of the init.sh project
# Copyright (c) 2019-2023 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# <Licence header compatible with BSD-3 licence, you want to use> # This file is distributed under 3-clause BSD license.
# The complete license agreement can be obtained at:
# https://opensource.org/licenses/BSD-3-Clause
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Variable list: # Variable list:
# * <VARNAME>: role explaination # * NFS_MOUNTS: list of mounts used in other variable names
# * MOUNTSERV_<mnt>: server acces to mount <mnt>
# * MOUNTPOINT_<mnt>: mount point for <mnt>
# * MOUNTOPTS_<mnt>: optionnaly, extra mount options for <mnt>
# ("defaults,_netdev" by default)
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Module version # Module version
export VER_conf_nfs="0.0.1" export VER_conf_nfs="0.0.2"
# Module's code # Module's code
conf_nfs() conf_nfs()
{ {
pkginst nfs-common pkginst nfs-common
for mnt in $NFS_MOUNTS; do for mnt in $NFS_MOUNTS; do
if [[ ! $(grep "$(eval echo \$MOUNTSERV_$mnt)/d" /etc/fstab) ]]; then local mnt_serv=${!MOUNTSERV_$mnt}
echo -e "$(eval echo \$MOUNTSERV_$mnt)\t$(eval echo \$MOUNTPOINT_$mnt)\tnfs4\tdefaults,_netdev\t0\t0" >> /etc/fstab local mnt_point="${!MOUNTPOINT_$mnt}"
local mnt_opts=${!MOUNTOPTS_$mnt:-"defaults,_netdev"}
if [[ -z $(grep "$mnt_serv" /etc/fstab) ]]; then
echo -e "${mnt_serv}\t${mnt_point}\tnfs4\t${mnt_opts}\t0\t0" >> /etc/fstab
fi fi
if [[ ! -d $(eval echo \$MOUNTPOINT_$mnt) ]]; then unset mnt_serv
mkdir -pv $(eval echo \$MOUNTPOINT_$mnt) if [[ ! -d $mnt_point ]]; then
mkdir -pv "$mnt_point"
fi fi
mount $(eval echo \$MOUNTPOINT_$mnt) mount "$mnt_point"
unset mnt_point
done done
} }

View File

@@ -38,15 +38,15 @@ conf_ntp()
prnt I "Installing NTP configuration file..." prnt I "Installing NTP configuration file..."
local dest="${conf_file}.work" local dest="${conf_file}.work"
backup_dist $conf_file backup_dist "$conf_file"
install_file ntp.conf $dest install_file ntp.conf "$dest"
tag_file $dest tag_file "$dest"
local line="" local line=""
for srv in $NTP_SERVERS; do for srv in $NTP_SERVERS; do
line="${line}server $srv iburst\n" line="${line}server $srv iburst\n"
done done
sed -i -e "s/@SERVERLIST@/$line/" $dest && sed -i -e "s/@SERVERLIST@/$line/" "$dest" &&
mv -fv $dest $conf_file mv -fv "$dest" "$conf_file"
prnt I "Starting service ntp..." prnt I "Starting service ntp..."

View File

@@ -32,13 +32,17 @@ install_chromium()
prnt I "Adding Debian Bullseye repository to software sources..." prnt I "Adding Debian Bullseye repository to software sources..."
install_file debian_bullseye.list /etc/apt/sources.list.d/ 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 esac
# Install Debian GPG keys # Install Debian GPG keys
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys DCC9EFBF77E11517 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 "648ACFD622F3D138"
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys AA8E81B4331F7F50 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 "112695A0E562B32A"
# Install package manager conf file for Chromium # Install package manager conf file for Chromium
install_file apt_chromium.conf /etc/apt/preferences.d/ install_file apt_chromium.conf /etc/apt/preferences.d/
@@ -69,6 +73,9 @@ precheck_install_chromium()
20.04|20.10|21.04|21.10) 20.04|20.10|21.04|21.10)
prnt m " * Detected Ubuntu $SYS_VER, will install Bullseye version of Chromium" 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." prnt E "Unable to determine the corresponding Debian version."
die 165 die 165

View File

@@ -24,12 +24,12 @@ install_desktop()
prnt I "Installing additionnal X11 drivers..." prnt I "Installing additionnal X11 drivers..."
pkginst $X11_DRV pkginst $X11_DRV
fi fi
if [[ $UBUNTU_FLAVOR ]]; then if [[ -n $UBUNTU_FLAVOR ]]; then
prnt I "Installing $UBUNTU_FLAVOR environment..." prnt I "Installing $UBUNTU_FLAVOR environment..."
pkginst ${UBUNTU_FLAVOR}-desktop pkginst ${UBUNTU_FLAVOR}-desktop
fi fi
# Because we're lazy but manual actions can avoid reboot... # Because we're lazy but manual actions can avoid reboot...
NEED_REBOOT=true export NEED_REBOOT=true
} }
precheck_install_desktop() precheck_install_desktop()

View File

@@ -25,7 +25,7 @@ install_pkg()
fi fi
# Blacklist some anoying packages (and remove them if needed) # 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 for pkg in $PKGS_BLACKLIST; do
prnt I "Placing $pkg into the blacklist..." prnt I "Placing $pkg into the blacklist..."
local dest=/etc/apt/preferences.d/blacklist_$pkg local dest=/etc/apt/preferences.d/blacklist_$pkg
@@ -51,13 +51,13 @@ install_pkg()
precheck_install_pkg() precheck_install_pkg()
{ {
if [[ -z PKGS_RMLIST ]]; then if [[ -z $PKGS_RMLIST ]]; then
prnt m " * No package to remove." prnt m " * No package to remove."
else else
prnt m " * $(echo $PKGS_RMLIST | wc -w) package to remove." prnt m " * $(echo $PKGS_RMLIST | wc -w) package to remove."
fi fi
if [[ -z PKGS_BLACKLIST ]]; then if [[ -z $PKGS_BLACKLIST ]]; then
prnt m " * The packages $pkg will be placed into the blacklist !" prnt m " * The packages $pkg will be placed into the blacklist !"
file_must_exists pkgman/blacklist.conf file_must_exists pkgman/blacklist.conf
else else

View File

@@ -30,7 +30,7 @@ install_profile()
#tag_file $usr/.tmux.conf{,.local} #tag_file $usr/.tmux.conf{,.local}
if [[ ! -d $usr/profile ]]; then if [[ ! -d $usr/profile ]]; then
( (
cd $usr cd $usr || return 205
git config --global http.sslverify false git config --global http.sslverify false
git clone https://git.geoffray-levasseur.org/fatalerrors/profile.git git clone https://git.geoffray-levasseur.org/fatalerrors/profile.git
git config --global http.sslverify true git config --global http.sslverify true

View File

@@ -20,7 +20,7 @@ select_system_proxy()
else else
prnt I "No proxy configuration set, nothing to do." prnt I "No proxy configuration set, nothing to do."
fi fi
NEED_REBOOT=true export NEED_REBOOT=true
} }
precheck_select_system_proxy() precheck_select_system_proxy()

View File

@@ -29,10 +29,12 @@ upgrade_dist()
# We backup entire apt dir # We backup entire apt dir
backup_dist /etc/apt backup_dist /etc/apt
prnt I "Basic apt configuration..." prnt I "Basic apt configuration..."
tag_file $norecommend tag_file $norecommends
echo 'APT::Install-Recommends "false";' >> $norecommends {
echo 'APT::AutoRemove::RecommendsImportant "false";' >> $norecommends echo 'APT::Install-Recommends "false";'
echo 'APT::AutoRemove::SuggestsImportant "false";' >> $norecommends echo 'APT::AutoRemove::RecommendsImportant "false";'
echo 'APT::AutoRemove::SuggestsImportant "false";'
} >> $norecommends
prnt I "Configuring proxy for APT..." prnt I "Configuring proxy for APT..."
if [[ -n $PROXY_APT ]]; then if [[ -n $PROXY_APT ]]; then