From a33726fba8b05c74013195f05dc9a8b306ae1e2e Mon Sep 17 00:00:00 2001 From: fatalerrors Date: Sat, 17 Dec 2022 20:19:03 +0100 Subject: [PATCH] fixed indentation --- init.sh | 100 ++++++------- lib/command_line.sh | 284 ++++++++++++++++++------------------ lib/diskman.sh | 142 +++++++++--------- lib/display.sh | 56 +++---- lib/filefct.sh | 190 ++++++++++++------------ lib/loaders.sh | 66 ++++----- lib/pkgman.sh | 110 +++++++------- lib/services.sh | 16 +- lib/support.sh | 18 +-- lib/utils.sh | 14 +- lib/version.sh | 44 +++--- modules/conf_network.sh | 236 +++++++++++++++--------------- modules/conf_ntp.sh | 24 +-- modules/conf_ssh.sh | 6 +- modules/create_vm.sh | 110 +++++++------- modules/install_chromium.sh | 54 +++---- modules/install_desktop.sh | 14 +- modules/install_mkagent.sh | 12 +- modules/install_pkg.sh | 40 ++--- modules/install_profile.sh | 14 +- modules/patch_snmp.sh | 16 +- modules/upgrade_dist.sh | 34 ++--- 22 files changed, 800 insertions(+), 800 deletions(-) diff --git a/init.sh b/init.sh index f761f6c..9ec6eda 100755 --- a/init.sh +++ b/init.sh @@ -152,12 +152,12 @@ fi # If cron mode, run cron tasks then exit if [[ $CRON_MODE == true ]]; then for mod in $MODULE_LIST; do - if [[ $(function_exists cron_$mod) ]]; then - prnt I "Running cron task for module $mod ..." - cron_$mod - else - prnt I "No cron task for module $mod." - fi + if [[ $(function_exists cron_$mod) ]]; then + prnt I "Running cron task for module $mod ..." + cron_$mod + else + prnt I "No cron task for module $mod." + fi done prnt I "All cron executed successfully!" exit 0 @@ -173,37 +173,37 @@ fi if [[ JUMP != true ]]; then tmpfile=$(mktemp /tmp/init-XXXXXX) if [[ -n $MANUAL_MODULE_LIST ]]; then - prnt W "Dependency checks are deactivated with a manual module list." + prnt W "Dependency checks are deactivated with a manual module list." fi if [[ $NO_DEPS == true ]]; then - prnt W "Dependency checks have been deactivated manually." + prnt W "Dependency checks have been deactivated manually." fi if [[ $RESUME == true ]]; then - cat $STAGE_FILE >> $tmpfile + cat $STAGE_FILE >> $tmpfile fi for mod in $MODULE_LIST; do - version=VER_$mod - if [[ $RESUME == true ]] && [[ $(grep $mod $STAGE_FILE) ]]; then - prnt I "Checks previously executed for $mod version ${!version}." - continue - fi - prnt I "Running initial checks for $mod version ${!version}..." - if [[ -z $MANUAL_MODULE_LIST && $NO_DEPS != true ]]; then - deps=DEP_$mod - for dep in ${!deps}; do - if [[ ! $(grep $dep $tmpfile) ]]; then - prnt E "Module $mod have unsatisfied dependencies or is executed too early." - prnt E " * $dep must be executed before $mod, please check your module list." - die 9 - fi - done - unset deps - fi - # We run in a subshell to protect main environment - ( - precheck_$mod - ) - echo $mod >> $tmpfile + version=VER_$mod + if [[ $RESUME == true ]] && [[ $(grep $mod $STAGE_FILE) ]]; then + prnt I "Checks previously executed for $mod version ${!version}." + continue + fi + prnt I "Running initial checks for $mod version ${!version}..." + if [[ -z $MANUAL_MODULE_LIST && $NO_DEPS != true ]]; then + deps=DEP_$mod + for dep in ${!deps}; do + if [[ ! $(grep $dep $tmpfile) ]]; then + prnt E "Module $mod have unsatisfied dependencies or is executed too early." + prnt E " * $dep must be executed before $mod, please check your module list." + die 9 + fi + done + unset deps + fi + # We run in a subshell to protect main environment + ( + precheck_$mod + ) + echo $mod >> $tmpfile done rm -f $tmpfile unset mod @@ -239,23 +239,23 @@ echo && separator && echo if [[ $key == "C" || $key == 'c' ]]; then # We launch modules one after one for mod in $MODULE_LIST; do - if [[ $RESUME == true ]] && [[ $(grep $mod $STAGE_FILE) ]]; then - continue - fi - # We need this only if JUMP is set but doesn't matter if it's done again - version=VER_$mod - prnt I "Applying changes for $mod version ${!version}..." - # Yet again, executed in a subshell - ( - export REBOOT_NEEDED=false - $mod - if [[ $REBOOT_NEEDED == true ]]; then - echo "$mod reboot" >> $STAGE_FILE # Mark as done for resuming - else - echo $mod >> $STAGE_FILE # Mark as done for resuming function - fi - ) - separator + if [[ $RESUME == true ]] && [[ $(grep $mod $STAGE_FILE) ]]; then + continue + fi + # We need this only if JUMP is set but doesn't matter if it's done again + version=VER_$mod + prnt I "Applying changes for $mod version ${!version}..." + # Yet again, executed in a subshell + ( + export REBOOT_NEEDED=false + $mod + if [[ $REBOOT_NEEDED == true ]]; then + echo "$mod reboot" >> $STAGE_FILE # Mark as done for resuming + else + echo $mod >> $STAGE_FILE # Mark as done for resuming function + fi + ) + separator done unset mod else @@ -268,8 +268,8 @@ echo if [[ -s $STAGE_FILE && $(grep " reboot" $STAGE_FILE) ]]; then prnt W "A reboot is required to apply some changes by the following packages:" prnt m " * $(grep ' reboot' $STAGE_FILE | \ - sed 's/ reboot//' | \ - sed ':a' -e 'N' -e '$!ba' -e 's/\n/ /g')" + sed 's/ reboot//' | \ + sed ':a' -e 'N' -e '$!ba' -e 's/\n/ /g')" prnt I "Please reboot now or as soon as possible!" echo fi diff --git a/lib/command_line.sh b/lib/command_line.sh index ca175df..e0fac79 100644 --- a/lib/command_line.sh +++ b/lib/command_line.sh @@ -16,8 +16,8 @@ read_commandline() { syntax_error() { - prnt E "Error while analysing command line parameters." - die 1 --force + prnt E "Error while analysing command line parameters." + die 1 --force } # Processing command line options @@ -27,117 +27,117 @@ read_commandline() local want_chroot=false local opt= for opt in $@; do - case $opt in - "-h"|"--help") - disp_help - exit 0 - ;; - "-v"|"--version") - show_version - exit 0 - ;; - "-m"|"--module") - local want_module=true - ;; - "-c"|"--check-only") - export CHECK_ONLY=true - ;; - "-j"|"--jump") - export JUMP=true - ;; - "-k"|"--keep-going") - export KEEPGOING=true - ;; - "-r"|"--resume") - if [[ -s $STAGE_FILE ]]; then - export RESUME=true - else - prnt E "The status file doesn't exists or is empty!" - prnt E "Without it, resuming is impossible." - die 17 --force - fi - ;; - "-R"|"--no-root-check") - export NO_ROOT_CHECK=true - ;; - "-D"|"--no-deps") - export NO_DEPS=true - ;; - "-o"|"--offline") - export OFFLINE=true - ;; - "-P"|"--no-proxy") - export NO_PROXY=true - ;; - "-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 - export NEW_LOGFILE=$opt - want_logfile=false - else - prnt E "Impossible to specify several log files." - die 1 --force - fi - elif [[ $want_conffile == true ]]; then - [[ $want_module == true ]] && synthax_error - [[ $want_logfile == true ]] && synthax_error - [[ $want_chroot == true ]] && synthax_error - export CONFFILES="$CONFFILES $opt" - want_logfile=false - elif [[ $want_chroot == true ]]; then - [[ $want_module == true ]] && synthax_error - [[ $want_logfile == true ]] && synthax_error - [[ $want_conffile == true ]] && synthax_error - if [[ -z $CHROOT_PATH ]]; then - export CHROOT_PATH=$opt - want_chroot=false - else - prnt E "A chroot path have already been given." - die 1 --force - fi - else - prnt E "Unknow parameter \"$opt\"." - die 1 --force - fi - ;; - esac + case $opt in + "-h"|"--help") + disp_help + exit 0 + ;; + "-v"|"--version") + show_version + exit 0 + ;; + "-m"|"--module") + local want_module=true + ;; + "-c"|"--check-only") + export CHECK_ONLY=true + ;; + "-j"|"--jump") + export JUMP=true + ;; + "-k"|"--keep-going") + export KEEPGOING=true + ;; + "-r"|"--resume") + if [[ -s $STAGE_FILE ]]; then + export RESUME=true + else + prnt E "The status file doesn't exists or is empty!" + prnt E "Without it, resuming is impossible." + die 17 --force + fi + ;; + "-R"|"--no-root-check") + export NO_ROOT_CHECK=true + ;; + "-D"|"--no-deps") + export NO_DEPS=true + ;; + "-o"|"--offline") + export OFFLINE=true + ;; + "-P"|"--no-proxy") + export NO_PROXY=true + ;; + "-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 + export NEW_LOGFILE=$opt + want_logfile=false + else + prnt E "Impossible to specify several log files." + die 1 --force + fi + elif [[ $want_conffile == true ]]; then + [[ $want_module == true ]] && synthax_error + [[ $want_logfile == true ]] && synthax_error + [[ $want_chroot == true ]] && synthax_error + export CONFFILES="$CONFFILES $opt" + want_logfile=false + elif [[ $want_chroot == true ]]; then + [[ $want_module == true ]] && synthax_error + [[ $want_logfile == true ]] && synthax_error + [[ $want_conffile == true ]] && synthax_error + if [[ -z $CHROOT_PATH ]]; then + export CHROOT_PATH=$opt + want_chroot=false + else + prnt E "A chroot path have already been given." + die 1 --force + fi + else + prnt E "Unknow parameter \"$opt\"." + die 1 --force + fi + ;; + esac done 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 + [[ $want_conffile == true ]] || [[ $want_chroot == true ]]; then + syntax_error fi unset want_conffile want_logfile want_module @@ -151,54 +151,54 @@ process_commandline_and_vars() { # Check unconsistant parameters if [[ $CHECK_ONLY == true ]]; then - if [[ $JUMP == true ]]; then - prnt E "The options --check-only and --jump are mutually exclusive!" - die 1 --force - fi - if [[ $KEEPGOING == true ]]; then - prnt E "The options --keep-going and --check-only are not compatible!" - die 1 --force - fi + if [[ $JUMP == true ]]; then + prnt E "The options --check-only and --jump are mutually exclusive!" + die 1 --force + fi + if [[ $KEEPGOING == true ]]; then + prnt E "The options --keep-going and --check-only are not compatible!" + die 1 --force + fi fi if [[ $RESUME == true ]]; then - if [[ $CHECK_ONLY == true ]]; then - prnt E "Resuming doesn't make sense with --check-only." - die 1 --force - fi - if [[ $MANUAL_MODULE_LIST ]]; then - prnt E "Recovery mode can't work with a manual module list." - die 1 --force - fi + if [[ $CHECK_ONLY == true ]]; then + prnt E "Resuming doesn't make sense with --check-only." + die 1 --force + fi + if [[ $MANUAL_MODULE_LIST ]]; then + prnt E "Recovery mode can't work with a manual module list." + die 1 --force + fi fi if [[ $CRON_MODE == true ]]; then - if [[ $CHECK_ONLY == true || $JUMP == true ]]; then - prnt E "Some parameters are incompatible with cron mode." - die 16 --force - fi + if [[ $CHECK_ONLY == true || $JUMP == true ]]; then + prnt E "Some parameters are incompatible with cron mode." + die 16 --force + fi fi # Configure module list if [[ -n $MANUAL_MODULE_LIST ]]; then - prnt W "A manual module list will be used." - export MODULE_LIST=$(echo $MANUAL_MODULE_LIST | sed "s/,/ /g") + prnt W "A manual module list will be used." + export MODULE_LIST=$(echo $MANUAL_MODULE_LIST | sed "s/,/ /g") fi # Check for module list existance and basic syntax if [[ -n $MODULE_LIST ]]; then - for mod in $MODULE_LIST; do - if [[ $mod =~ ['-!@#$%\&*=+'] ]]; then - prnt E "The module \"$mod\" contains a forbidden character in its name." - die 5 - fi - if [[ ! -s "modules/$mod.sh" ]]; then - prnt E "The asked module \"$mod\", doesn't have any module file or module file is empty." - die 18 - fi - done + for mod in $MODULE_LIST; do + if [[ $mod =~ ['-!@#$%\&*=+'] ]]; then + prnt E "The module \"$mod\" contains a forbidden character in its name." + die 5 + fi + if [[ ! -s "modules/$mod.sh" ]]; then + prnt E "The asked module \"$mod\", doesn't have any module file or module file is empty." + die 18 + fi + done else - prnt E "No module to execute!" - die 5 + prnt E "No module to execute!" + die 5 fi } export -f process_commandline_and_vars diff --git a/lib/diskman.sh b/lib/diskman.sh index 991ff16..8249dae 100644 --- a/lib/diskman.sh +++ b/lib/diskman.sh @@ -14,23 +14,23 @@ blank_disk() { if [[ -b /dev/$1 ]]; then - prnt I "Wipping $1 drive signature (a backup is made in /root)..." - wipefs --force --all --backup /dev/$1 - prnt I "Filling beginning of $1 drive with zeroes..." - if [[ $2 == "--full" ]]; then - # If full we display progress as it might take a very long time - # Need true to avoid error as the last byte will generate a disk - # full error - dd if="/dev/zero" of="$1" bs="512" status=progress || true - else - dd if="/dev/zero" of="$1" bs="512" count="1024" - fi + prnt I "Wipping $1 drive signature (a backup is made in /root)..." + wipefs --force --all --backup /dev/$1 + prnt I "Filling beginning of $1 drive with zeroes..." + if [[ $2 == "--full" ]]; then + # If full we display progress as it might take a very long time + # Need true to avoid error as the last byte will generate a disk + # full error + dd if="/dev/zero" of="$1" bs="512" status=progress || true + else + dd if="/dev/zero" of="$1" bs="512" count="1024" + fi - # Update kernel partition scheme - partprobe + # Update kernel partition scheme + partprobe else - prnt E "The /dev/$1 file is not a bloc device!" - die 19 + prnt E "The /dev/$1 file is not a bloc device!" + die 19 fi } export -f blank_disk @@ -44,16 +44,16 @@ export -f blank_disk is_blank() { if [[ -b /dev/$1 ]]; then - # That technique is fast but might not be relayable enough if we are on - # exotic data structure or filesystem... - local devstat=$(file /dev/$1 | sed "s@/dev/$1: @@") - if [[ $devstat == 'data' ]]; then - return 0 - else - return 1 - fi + # That technique is fast but might not be relayable enough if we are on + # exotic data structure or filesystem... + local devstat=$(file /dev/$1 | sed "s@/dev/$1: @@") + if [[ $devstat == 'data' ]]; then + return 0 + else + return 1 + fi else - return 2 + return 2 fi } export -f is_blank @@ -69,37 +69,37 @@ mkparts() { local device=$1 && shit if [[ $1 == "gtp" || $1 == "dos" ]]; then - local parttype=$1 && shift + local parttype=$1 && shift else - # Default is GPT - local parttype="gpt" + # Default is GPT + local parttype="gpt" fi if [[ $(is_blank $device) ]]; then - prnt I "Creating a new ${parttype^^} partition table on $device..." - sfdisk -label /dev/$device $parttype - prnt I "Creating a new partition scheme on /dev/$1..." - local tmpfile=$(mktemp sfd.XXXX) - if [[ -n $1 ]]; then - # For each given size we make a partition - for $part in $@; do - # If size is zero we interpret it as all available space - if [[ $part == 0 ]]; then - echo ",,L" >> $tmpfile - else - echo ",$part,L" >> $tmpfile - fi - done - else - echo ",,L" >> $tmpfile - fi - echo "write" >> $tmpfile - sfdisk "/dev/$device" < $tmpfile - rm $tmpfile - unset tmpfile + prnt I "Creating a new ${parttype^^} partition table on $device..." + sfdisk -label /dev/$device $parttype + prnt I "Creating a new partition scheme on /dev/$1..." + local tmpfile=$(mktemp sfd.XXXX) + if [[ -n $1 ]]; then + # For each given size we make a partition + for $part in $@; do + # If size is zero we interpret it as all available space + if [[ $part == 0 ]]; then + echo ",,L" >> $tmpfile + else + echo ",$part,L" >> $tmpfile + fi + done + else + echo ",,L" >> $tmpfile + fi + echo "write" >> $tmpfile + sfdisk "/dev/$device" < $tmpfile + rm $tmpfile + unset tmpfile else - prnt E "The $1 block device is not blank, for security we won't proceed!" - die 20 + prnt E "The $1 block device is not blank, for security we won't proceed!" + die 20 fi unset device parttype } @@ -111,12 +111,12 @@ export -f mkparts mkfs_gen() { for drv in $@; do - if [[ -b /dev/$drv ]]; then - $mkfstool $MKFSOPT /dev/$drv - else - prnt E "/dev/$drv is not a bloc device!" - die 18 - fi + if [[ -b /dev/$drv ]]; then + $mkfstool $MKFSOPT /dev/$drv + else + prnt E "/dev/$drv is not a bloc device!" + die 18 + fi done } @@ -125,9 +125,9 @@ mkfs_gen() # Format drive using ext4 filesystem, parameters will be a list of block device mkext4() { - export mkfstool="mkfs.ext4" - mkfs_gen $@ - unset mkfstool + export mkfstool="mkfs.ext4" + mkfs_gen $@ + unset mkfstool } export -f mkext4 @@ -136,9 +136,9 @@ export -f mkext4 # Format a XFS filesystem... mkxfs() { - export mkfstool="mkfs.xfs" - mkfs_gen $@ - unset mkfstool + export mkfstool="mkfs.xfs" + mkfs_gen $@ + unset mkfstool } export -f mkxfs @@ -147,9 +147,9 @@ export -f mkxfs # ... NTFS ... mkntfs() { - export mkfstool="mkfs.ntfs" - mkfs_gen $@ - unset mkfstool + export mkfstool="mkfs.ntfs" + mkfs_gen $@ + unset mkfstool } export -f mkntfs @@ -158,9 +158,9 @@ export -f mkntfs # ... FAT32 ... mkfat32() { - export mkfstool="mkfs.vfat" - mkfs_gen $@ - unset mkfstool + export mkfstool="mkfs.vfat" + mkfs_gen $@ + unset mkfstool } export -f mkfat32 @@ -169,9 +169,9 @@ export -f mkfat32 # ... BTRFS ... mkbtrfs() { - export mkfstool="mkfs.btrfs" - mkfs_gen $@ - unset mkfstool + export mkfstool="mkfs.btrfs" + mkfs_gen $@ + unset mkfstool } export -f mkbtrfs diff --git a/lib/display.sh b/lib/display.sh index 0f71144..45199b2 100644 --- a/lib/display.sh +++ b/lib/display.sh @@ -94,28 +94,28 @@ export On_IWhite='\e[0;107m' prnt() { if [[ $1 == "-n" ]]; then - local echoopt=$1 - shift + local echoopt=$1 + shift else - local echoopt="" + local echoopt="" fi case $1 in - "I") - local heads="[ ${IGreen}info${DEFAULTFG} ]" - shift - ;; - "W") - local heads="[${IYellow}Warning${DEFAULTFG}]" - shift - ;; - "E") - local heads="[ ${IRed}ERROR${DEFAULTFG} ]" - shift - ;; - "m") - local heads=" " - shift - ;; + "I") + local heads="[ ${IGreen}info${DEFAULTFG} ]" + shift + ;; + "W") + local heads="[${IYellow}Warning${DEFAULTFG}]" + shift + ;; + "E") + local heads="[ ${IRed}ERROR${DEFAULTFG} ]" + shift + ;; + "m") + local heads=" " + shift + ;; esac echo $echoopt -e "${IWhite}$(date $DATEFORMAT)${DEFAULTFG} ${heads} $@" @@ -132,10 +132,10 @@ separator() local i=0 declare -li length=$(( $(tput cols) - 1 )) if [[ $length -gt 80 ]]; then - length=$(( $length - (($length - 80) / 2) )) + length=$(( $length - (($length - 80) / 2) )) fi for i in $(seq 1 $length); do - echo -n "-" + echo -n "-" done echo -e "$DEFAULTCOL" unset i length @@ -150,13 +150,13 @@ dsleep() i=$1 while test $i -gt 0 do - if [[ -n $2 ]]; then - echo -n "$2" - else - echo -n " ${i}" - fi - (( i=i-1 )) - sleep 1 + if [[ -n $2 ]]; then + echo -n "$2" + else + echo -n " ${i}" + fi + (( i=i-1 )) + sleep 1 done echo } diff --git a/lib/filefct.sh b/lib/filefct.sh index b92b763..271ad41 100644 --- a/lib/filefct.sh +++ b/lib/filefct.sh @@ -21,35 +21,35 @@ export COMM_REPO_PATH=${COMM_REPO_PATH:-"$MYPATH/repo/common"} backup_dist() { if [[ $# -lt 1 ]]; then - prnt E "backup_dist(): At least one argument is required." - exit 11 + prnt E "backup_dist(): At least one argument is required." + exit 11 fi local file= for file in $@; do - local tmstmp=$(stdtime) - if [[ -L ${file} ]]; then - # With symbolik links we call again backup_dist to treat target + local tmstmp=$(stdtime) + if [[ -L ${file} ]]; then + # With symbolik links we call again backup_dist to treat target prnt I "Following the symbolic link $file to do a proper backup..." - backup_dist $(readlink -f ${file}) - elif [[ -f ${file} ]]; then - prnt I "Creating a backup of ${file} on $tmstmp..." - cp -av $file ${file}.dist.${tmstmp} - if [[ $? -ne 0 ]]; then - prnt E "backup_dist(): Failed copying file." - die 12 - fi - elif [[ -d ${file} ]]; then - prnt I "Creation a backup of the directory ${file} on $tmstmp..." - cp -av $file ${file}.dist.${tmstmp} - if [[ $? -ne 0 ]]; then - prnt E "backup_dist(): Failed copyind directory recursively." - die 12 - fi - else - prnt W "backup_dist(): $file don't exists, nothing to do." - fi - unset tmstmp + backup_dist $(readlink -f ${file}) + elif [[ -f ${file} ]]; then + prnt I "Creating a backup of ${file} on $tmstmp..." + cp -av $file ${file}.dist.${tmstmp} + if [[ $? -ne 0 ]]; then + prnt E "backup_dist(): Failed copying file." + die 12 + fi + elif [[ -d ${file} ]]; then + prnt I "Creation a backup of the directory ${file} on $tmstmp..." + cp -av $file ${file}.dist.${tmstmp} + if [[ $? -ne 0 ]]; then + prnt E "backup_dist(): Failed copyind directory recursively." + die 12 + fi + else + prnt W "backup_dist(): $file don't exists, nothing to do." + fi + unset tmstmp done unset file } @@ -62,12 +62,12 @@ select_file() { local infile=$1 if [[ -f $HOST_REPO_PATH/$infile ]]; then - local source="$HOST_REPO_PATH/$infile" + local source="$HOST_REPO_PATH/$infile" elif [[ -f $COMM_REPO_PATH/$infile ]]; then - local source="$COMM_REPO_PATH/$infile" + local source="$COMM_REPO_PATH/$infile" else - # Not found in repository, we expect full name - local source="$infile" + # Not found in repository, we expect full name + local source="$infile" fi unset infile echo $source @@ -82,12 +82,12 @@ select_directory() { local indir=$1 if [[ -d $HOST_REPO_PATH/$indir ]]; then - local source="$HOST_REPO_PATH/$indir" + local source="$HOST_REPO_PATH/$indir" elif [[ -d $COMM_REPO_PATH/$indir ]]; then - local source="$COMM_REPO_PATH/$indir" + local source="$COMM_REPO_PATH/$indir" else - # Not found in repository, we expect full name - local source="$indir" + # Not found in repository, we expect full name + local source="$indir" fi unset indir echo $source @@ -105,44 +105,44 @@ install_file() local i=0 if [[ $# -lt 2 ]]; then - prnt E "install_file(): At least two arguments are required." - die 11 + prnt E "install_file(): At least two arguments are required." + die 11 fi if [[ $(echo $@ | grep "\*\|\?") ]]; then - prnt E "install_file(): Wildcards are not authorized." - die 7 + prnt E "install_file(): Wildcards are not authorized." + die 7 fi local arg= for arg in $@; do - filelist="$filelist $(select_file $arg)" + filelist="$filelist $(select_file $arg)" done unset arg # Empty to just obtain the target which is the last element of the list local file= for file in $filelist; do - : + : done if [[ ! $file == /* ]]; then - prnt E "install_file(): Target must be on the root filesystem and full path must be provided." - die 13 + prnt E "install_file(): Target must be on the root filesystem and full path must be provided." + die 13 fi unset file if [[ -d $(dirname $i) ]]; then - prnt I "Creating required target directory $(dirname $i)..." - mkdir -pv $(dirname $i) - if [[ $? -ne 0 ]]; then - prnt E "install_file(): Can't create target directory!" - die 12 - fi + prnt I "Creating required target directory $(dirname $i)..." + mkdir -pv $(dirname $i) + if [[ $? -ne 0 ]]; then + prnt E "install_file(): Can't create target directory!" + die 12 + fi fi prnt I "Copying files ${filelist} to target directory $(dirname $i)..." cp -av $filelist if [[ $? -ne 0 ]]; then - prnt E "install_file(): Couldn't copy some required files!" - die 12 + prnt E "install_file(): Couldn't copy some required files!" + die 12 fi } export -f install_file @@ -155,19 +155,19 @@ append_file() local srcfile=$(select_file $1) local dstfile=$2 if [[ -e $dstfile ]]; then - prnt E "append_file(): Target must be on the root filesystem and full path must be provided." - die 13 + prnt E "append_file(): Target must be on the root filesystem and full path must be provided." + die 13 fi if [[ ! $dstfile == /* ]]; then - prnt E "append_file(): Target file must exist." - die 13 + prnt E "append_file(): Target file must exist." + die 13 fi prnt I "Adding content to file $dstfile..." cat $srcfile >> $dstfile if [[ $? -ne 0 ]]; then - prnt E "append_file(): Couldn't append a file!" - die 12 + prnt E "append_file(): Couldn't append a file!" + die 12 fi } export -f append_file @@ -180,16 +180,16 @@ is_dir_empty() dir=$1 if [[ -f $dir ]]; then - prnt E "is_dir_empty(): The given parameter is not a directory." - die 15 + prnt E "is_dir_empty(): The given parameter is not a directory." + die 15 fi if [[ ! -d $dir ]]; then - return 0 + return 0 fi nbfiles=$(ls -a1 $dir | egrep -v '^.$|^..$' | wc -l) if [[ $nbfiles -eq 0 ]]; then - return 0 + return 0 fi return 1 } @@ -206,29 +206,29 @@ patch_file() local workfile=${dstfile}.work if [[ ! -s $srcfile ]]; then - prnt E "patch_file(): Source file is empty, is not a file or don't exists!" - die 10 + prnt E "patch_file(): Source file is empty, is not a file or don't exists!" + die 10 fi # Create a sub-process, to avoid bash environment pollution ( - local varlist= pattern= - if [[ $# -eq 0 ]] ; then - pattern="-e s/<\(.*\)>/\$\1\$\1/g" - else - local var= - for var in $* ; do - if ! declare -p $var >/dev/null 2>&1 ; then - local $var=$(eval echo \$$var) - fi - export $var - pattern="$pattern -e s/@$var@/\$$var/g" - varlist=$varlist\$$var - done - fi + local varlist= pattern= + if [[ $# -eq 0 ]] ; then + pattern="-e s/<\(.*\)>/\$\1\$\1/g" + else + local var= + for var in $* ; do + if ! declare -p $var >/dev/null 2>&1 ; then + local $var=$(eval echo \$$var) + fi + export $var + pattern="$pattern -e s/@$var@/\$$var/g" + varlist=$varlist\$$var + done + fi - # sed replace with \$$VAR and envsubst do the replace by value - sed $pattern $srcfile | envsubst ${varlist:+"$varlist"} > "$workfile" + # sed replace with \$$VAR and envsubst do the replace by value + sed $pattern $srcfile | envsubst ${varlist:+"$varlist"} > "$workfile" ) local -a rights=( $(stat --printf="%a %u %g" "$srcfile") ) @@ -247,13 +247,13 @@ export -f patch_file tag_file() { for f in $@; do - local text="# File automatically modified by init.sh on $(stdtime)." - if [[ -e $f ]]; then - sed -i "1s/^/$text\n/" $f - else - echo $text > $f - sed -i -e "s/modified/generated/" $f - fi + local text="# File automatically modified by init.sh on $(stdtime)." + if [[ -e $f ]]; then + sed -i "1s/^/$text\n/" $f + else + echo $text > $f + sed -i -e "s/modified/generated/" $f + fi done } export -f tag_file @@ -264,10 +264,10 @@ export -f tag_file file_exists() { for f in $@; do - if [[ ! -f $(select_file $f) ]]; then - echo $f - return 1 - fi + if [[ ! -f $(select_file $f) ]]; then + echo $f + return 1 + fi done return 0 } @@ -281,8 +281,8 @@ 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 + prnt E "file_must_exists(): The $mf file is missing, can't continue." + die 10 fi unset mf } @@ -294,10 +294,10 @@ export -f file_must_exists directory_exists() { for d in $@; do - if [[ ! -d $(select_directory $d) ]]; then - echo $d - return 1 - fi + if [[ ! -d $(select_directory $d) ]]; then + echo $d + return 1 + fi done return 0 } @@ -310,8 +310,8 @@ 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 + prnt E "directory_must_exists(): The $md directory is missing, can't continue." + die 10 fi unset md } diff --git a/lib/loaders.sh b/lib/loaders.sh index 9a3de4a..5832e40 100644 --- a/lib/loaders.sh +++ b/lib/loaders.sh @@ -24,25 +24,25 @@ load_autoconf() local prefix="$MYPATH/conf/auto" if [[ -e $prefix/$SYS_ARCH.conf.sh ]]; then - . $prefix/$SYS_ARCH.conf.sh + . $prefix/$SYS_ARCH.conf.sh fi if [[ -e $prefix/$SYS_DIST.conf.sh ]]; then - . $prefix/$SYS_DIST.conf.sh + . $prefix/$SYS_DIST.conf.sh fi if [[ -e $prefix/$SYS_DIST-$SYS_ARCH.conf.sh ]]; then - . $prefix/$SYS_DIST-$SYS_ARCH.conf.sh + . $prefix/$SYS_DIST-$SYS_ARCH.conf.sh fi if [[ -e $prefix/$SYS_DIST-$SYS_VER.conf.sh ]]; then - . $prefix/$SYS_DIST-$SYS_VER.conf.sh + . $prefix/$SYS_DIST-$SYS_VER.conf.sh fi if [[ -n $SYS_CODE && -e $prefix/$SYS_DIST-$SYS_CODE.conf.sh ]]; then - . $prefix/$SYS_DIST-$SYS_CODE.conf.sh + . $prefix/$SYS_DIST-$SYS_CODE.conf.sh fi if [[ -e $prefix/$SYS_DIST-$SYS_VER-$SYS_ARCH.conf.sh ]]; then - . $prefix/$SYS_DIST-$SYS_VER-$SYS_ARCH.conf.sh + . $prefix/$SYS_DIST-$SYS_VER-$SYS_ARCH.conf.sh fi if [[ -n $SYS_CODE && -e $prefix/$SYS_DIST-$SYS_CODE-$SYS_ARCH.conf.sh ]]; then - . $prefix/$SYS_DIST-$SYS_CODE-$SYS_ARCH.conf.sh + . $prefix/$SYS_DIST-$SYS_CODE-$SYS_ARCH.conf.sh fi unset prefix @@ -58,31 +58,31 @@ export -f load_autoconf load_configuration() { if [[ -n $CONFFILES ]]; then - local f= - for f in $CONFFILES; do - prnt I "Loading $f manually specified." - if [[ -s $f ]]; then - . $f - else - prnt E "The $f file doesn't exists or is empty." - die 6 --force - fi - done - unset f + local f= + for f in $CONFFILES; do + prnt I "Loading $f manually specified." + if [[ -s $f ]]; then + . $f + else + prnt E "The $f file doesn't exists or is empty." + die 6 --force + fi + done + unset f else - prnt I "Loading configuration..." - if [[ -e $MYPATH/conf/$HOSTNAME.conf.sh ]]; then - prnt I "A specific configuration will be used." - . $MYPATH/conf/$HOSTNAME.conf.sh - else - if [[ -e $MYPATH/conf/init.conf.sh ]]; then - prnt I "A generic configuration will be used." - . $MYPATH/conf/init.conf.sh - else - prnt E "No configuration found, impossible to continue." - die 6 --force - fi - fi + prnt I "Loading configuration..." + if [[ -e $MYPATH/conf/$HOSTNAME.conf.sh ]]; then + prnt I "A specific configuration will be used." + . $MYPATH/conf/$HOSTNAME.conf.sh + else + if [[ -e $MYPATH/conf/init.conf.sh ]]; then + prnt I "A generic configuration will be used." + . $MYPATH/conf/init.conf.sh + else + prnt E "No configuration found, impossible to continue." + die 6 --force + fi + fi fi } export -f load_configuration @@ -94,8 +94,8 @@ load_prepost_actions() { local prepost= for prepost in $MYPATH/prepost.d/*.sh; do - prnt I "Loading prepost actions in $prepost ..." - . $prepost + prnt I "Loading prepost actions in $prepost ..." + . $prepost done unset prepost } diff --git a/lib/pkgman.sh b/lib/pkgman.sh index 6c33c17..afdf6fc 100644 --- a/lib/pkgman.sh +++ b/lib/pkgman.sh @@ -25,21 +25,21 @@ pkginst() { prnt I "Installing packages..." if [[ $# -lt 1 ]]; then - prnt E "pkginst(): some required parameters are missing." - exit 11 + prnt E "pkginst(): some required parameters are missing." + exit 11 fi if [[ ! $INSTALL_MODE == dev ]]; then - exec_preinst $@ - $PKG_MAN $COM_INSTALL $@ - exec_postinst + exec_preinst $@ + $PKG_MAN $COM_INSTALL $@ + exec_postinst else - local pkg= - for pkg in $@; do - exec_preinst $pkg - $PKG_MAN $COM_INSTALL $pkg - exec_postinst - done - unset pkg + local pkg= + for pkg in $@; do + exec_preinst $pkg + $PKG_MAN $COM_INSTALL $pkg + exec_postinst + done + unset pkg fi } export -f pkginst @@ -63,21 +63,21 @@ pkgrm() { prnt I "Uninstalling packages..." if [[ $# -lt 1 ]]; then - prnt E "pkgrem(): some required parameters are missing." - exit 11 + prnt E "pkgrem(): some required parameters are missing." + exit 11 fi if [[ ! $INSTALL_MODE == dev ]]; then - exec_prerm $@ - $PKG_MAN $COM_REMOVE $@ - exec_postrm + exec_prerm $@ + $PKG_MAN $COM_REMOVE $@ + exec_postrm else - local pkg= - for pkg in $@; do - exec_prerm $pkg - $PKG_MAN $COM_REMOVE $pkg - exec_postrm - done - uset pkg + local pkg= + for pkg in $@; do + exec_prerm $pkg + $PKG_MAN $COM_REMOVE $pkg + exec_postrm + done + uset pkg fi } export -f pkgrm @@ -101,10 +101,10 @@ exec_preinst() { local pkglist=$(get_install_list $@) for pkg in $pkglist; do - if [[ $(function_exists preinst_$pkg) ]]; then - prnt I "Running $pkg preinstallation script..." - preinst_$pkg - fi + if [[ $(function_exists preinst_$pkg) ]]; then + prnt I "Running $pkg preinstallation script..." + preinst_$pkg + fi done export POSTINSTLIST=$pkglist unset pkglist @@ -117,13 +117,13 @@ export -f exec_preinst exec_postinst() { if [[ -z $POSTINSTLIST ]]; then - return 0 + return 0 fi for pkg in $POSTINSTLIST; do - if [[ $(function_exists postinst_$pkg) ]]; then - prnt I "Running $pkg postinstallation script..." - postinst_$pkg - fi + if [[ $(function_exists postinst_$pkg) ]]; then + prnt I "Running $pkg postinstallation script..." + postinst_$pkg + fi done unset POSTINSTLIST } @@ -137,10 +137,10 @@ exec_prerm() local pkglist=$(get_remove_list $@) unset $cmd for pkg in $pkglist; do - if [[ $(function_exists prerm_$pkg) ]]; then - prnt I "Running $pkg preremove script..." - prerm_$pkg - fi + if [[ $(function_exists prerm_$pkg) ]]; then + prnt I "Running $pkg preremove script..." + prerm_$pkg + fi done export POSTRMLIST=$pkglist unset pkglist @@ -153,13 +153,13 @@ export -f exec_prerm exec_postrm() { if [[ -z $POSTRMLIST ]]; then - return 0 + return 0 fi for pkg in $POSTRMLIST; do - if [[ $(function_exists postrm_$pkg) ]]; then - prnt I "Running $pkg postremove script..." - postrm_$pkg - fi + if [[ $(function_exists postrm_$pkg) ]]; then + prnt I "Running $pkg postremove script..." + postrm_$pkg + fi done unset POSTRMLIST } @@ -172,10 +172,10 @@ exec_preupgd() { local pkglist=$(get_upgrade_list) for pkg in $pkglist; do - if [[ $(function_exists preupgd_$pkg) ]]; then - prnt I "Running $pkg preupgrade script..." - preupgd_$pkg - fi + if [[ $(function_exists preupgd_$pkg) ]]; then + prnt I "Running $pkg preupgrade script..." + preupgd_$pkg + fi done export POSTUPGDLIST=$pkglist unset pkglist @@ -188,13 +188,13 @@ export -f exec_preupgd exec_postupgd() { if [[ -z $POSTUPGDLIST ]]; then - return 0 + return 0 fi for pkg in $POSTUPGDLIST; do - if [[ $(function_exists postupgd_$pkg) ]]; then - prnt I "Running $pkg postupgrade script..." - postupgd_$pkg - fi + if [[ $(function_exists postupgd_$pkg) ]]; then + prnt I "Running $pkg postupgrade script..." + postupgd_$pkg + fi done unset POSTUPGDLIST } @@ -207,10 +207,10 @@ exec_preautorm() { local pkglist=$(get_autorem_list) for pkg in $pkglist; do - if [[ $(function_exists prerm_$pkg) ]]; then - prnt I "Running $pkg preremove script..." - prerm_$pkg - fi + if [[ $(function_exists prerm_$pkg) ]]; then + prnt I "Running $pkg preremove script..." + prerm_$pkg + fi done export POSTRMLIST=$pkglist unset pkglist diff --git a/lib/services.sh b/lib/services.sh index 55c157a..453b367 100644 --- a/lib/services.sh +++ b/lib/services.sh @@ -15,16 +15,16 @@ exec_serv() { if [[ $# -lt 2 ]]; then - prnt E "exec_serv(): Syntax error (parameters: $@)!" - exit 11 + prnt E "exec_serv(): Syntax error (parameters: $@)!" + exit 11 fi local svcname=$1 command=$2 shift 2 local lineexec=$(echo $INIT_COM | - sed -e s/%srv%/$svcname/ \ - -e s/%com%/$command/) + sed -e s/%srv%/$svcname/ \ + -e s/%com%/$command/) unset svcname command prnt I "Launching command $command for the service $svcname" @@ -41,7 +41,7 @@ svc_start() { local svc= for svc in $@; do - exec_serv $svc start + exec_serv $svc start done unset svc } @@ -53,7 +53,7 @@ export -f svc_start svc_reload() { for svc in $@; do - exec_serv $svc reload + exec_serv $svc reload done } export -f svc_reload @@ -65,7 +65,7 @@ svc_restart() { local svc= for svc in $@; do - exec_serv $svc restart + exec_serv $svc restart done unset svc } @@ -78,7 +78,7 @@ svc_stop() { local svc= for svc in $@; do - exec_serv $svc stop + exec_serv $svc stop done unset svc } diff --git a/lib/support.sh b/lib/support.sh index be28ea9..6873476 100644 --- a/lib/support.sh +++ b/lib/support.sh @@ -84,21 +84,21 @@ show_version() local mod= for mod in $MYPATH/modules/*.sh; do - # Ran in a subshell to not pollute environment - ( - . $mod - local modname=$(get_mod_name $mod) - local version=VER_$modname + # Ran in a subshell to not pollute environment + ( + . $mod + local modname=$(get_mod_name $mod) + local version=VER_$modname - echo -e "\t$BWhite$modname${DEFAULTCOL}: $BGreen${!version}$DEFAULTCOL" + echo -e "\t$BWhite$modname${DEFAULTCOL}: $BGreen${!version}$DEFAULTCOL" - unset modname version - ) + unset modname version + ) done unset mod if [[ $(id -u) -ne 0 ]]; then - echo -e "\n${BYellow}Warning:$DEFAULTCOL That script requires superuser rights to work." + echo -e "\n${BYellow}Warning:$DEFAULTCOL That script requires superuser rights to work." fi } export -f show_version diff --git a/lib/utils.sh b/lib/utils.sh index 55c7a91..a55a377 100644 --- a/lib/utils.sh +++ b/lib/utils.sh @@ -21,14 +21,14 @@ export -f stdtime # Check if a function exists, return 0 if so function_exists() { if [[ $# -ne 1 ]]; then - prnt E "function_exists(): A function name is required!" - die 11 --force + prnt E "function_exists(): A function name is required!" + die 11 --force fi if [[ $(LC_ALL=C type -t $1 | grep function) ]]; then - return 0 + return 0 else - return 1 + return 1 fi } export -f function_exists @@ -39,8 +39,8 @@ export -f function_exists get_mod_name() { if [[ $# -ne 1 ]]; then - prnt E "get_mod_name(): Bad number of parameters." - die 11 --force + prnt E "get_mod_name(): Bad number of parameters." + die 11 --force fi echo $(basename $1 | cut -f 1 -d '.') } @@ -62,7 +62,7 @@ export -f trim dump_key_buffer() { while read -r -t 0.001; do - : + : done } export -f dump_key_buffer diff --git a/lib/version.sh b/lib/version.sh index 475d8dd..801d507 100644 --- a/lib/version.sh +++ b/lib/version.sh @@ -13,32 +13,32 @@ get_os_version() { if [[ ! -f /etc/os-release ]]; then - prnt E "get_os_version(): Your distribution doesn't have the needed os-release file." - die 8 --force + prnt E "get_os_version(): Your distribution doesn't have the needed os-release file." + die 8 --force fi # Create a sub-shell to avoid polluting the environnement ( - # Iniitalise version codename in case the var don't exists - VERSION_CODENAME="NULL" + # Iniitalise version codename in case the var don't exists + VERSION_CODENAME="NULL" - # Import the file in the environment - source /etc/os-release + # Import the file in the environment + source /etc/os-release - if [[ -z $ID ]]; then - prnt E "get_os_version(): Your /etc/os-release file mises some vital information." - die 8 --force - fi + if [[ -z $ID ]]; then + prnt E "get_os_version(): Your /etc/os-release file mises some vital information." + die 8 --force + fi - if [[ -z $VERSION_ID ]]; then - local maj=$(uname -r | cut -d'.' -f1) - local min=$(uname -r | cut -d'.' -f2) - VERSION_ID="$maj.$min" - unset maj min - fi + if [[ -z $VERSION_ID ]]; then + local maj=$(uname -r | cut -d'.' -f1) + local min=$(uname -r | cut -d'.' -f2) + VERSION_ID="$maj.$min" + unset maj min + fi - # Return values on stdout - echo ${ID,,} ${VERSION_ID} ${VERSION_CODENAME,,} + # Return values on stdout + echo ${ID,,} ${VERSION_ID} ${VERSION_CODENAME,,} ) } export read_os_release @@ -50,17 +50,17 @@ export read_os_release set_sys_vars() { if [[ $# -ne 4 ]]; then - prnt E "set_sys_vars(): Incorrect number of parameters ($@)." - die 7 --force + prnt E "set_sys_vars(): Incorrect number of parameters ($@)." + die 7 --force fi export SYS_ARCH=$1 export SYS_DIST=$2 export SYS_VER=$3 if [[ $4 != "null" ]]; then - export SYS_CODE=$4 + export SYS_CODE=$4 elif [[ -n $SYS_CODE ]]; then - unset SYS_CODE + unset SYS_CODE fi } export -f get_os_version diff --git a/modules/conf_network.sh b/modules/conf_network.sh index be0ec38..eb44d6a 100644 --- a/modules/conf_network.sh +++ b/modules/conf_network.sh @@ -35,69 +35,69 @@ conf_network() # First configure IPv4 ifaces local iface= for iface in $IPV4_IFACES; do - echo -e "\n# --------------------------------\n" >> $if_file + echo -e "\n# --------------------------------\n" >> $if_file - if [[ $(eval echo \$NET4_MODE_$iface) == static ]]; then - prnt I "Configuring IPv4 network interface $iface in static mode..." - echo "auto $iface" >> $if_file - echo "iface $iface inet static" >> $if_file - echo -e "\taddress $(eval echo \$NET4_IP_$iface)" >> $if_file + if [[ $(eval echo \$NET4_MODE_$iface) == static ]]; then + prnt I "Configuring IPv4 network interface $iface in static mode..." + echo "auto $iface" >> $if_file + echo "iface $iface inet static" >> $if_file + echo -e "\taddress $(eval echo \$NET4_IP_$iface)" >> $if_file - if [[ -n $(eval echo \$NET4_GW_$iface) ]]; then - echo -e "\tgateway $(eval echo \$NET4_GW_$iface)" >> $if_file - fi + if [[ -n $(eval echo \$NET4_GW_$iface) ]]; then + echo -e "\tgateway $(eval echo \$NET4_GW_$iface)" >> $if_file + fi - if [[ -n $(eval echo \$NET4_NS_$iface) ]]; then - echo -e "\tdns_nameservers $(eval echo \$NET4_NS_$iface)" >> $if_file - fi + if [[ -n $(eval echo \$NET4_NS_$iface) ]]; then + echo -e "\tdns_nameservers $(eval echo \$NET4_NS_$iface)" >> $if_file + fi - if [[ -n $(eval echo \$NET4_NS_SEARCH_$iface) ]]; then - echo -e "\tdns_search $(eval echo \$NET4_NS_SEARCH_$iface)" >> $if_file - fi + if [[ -n $(eval echo \$NET4_NS_SEARCH_$iface) ]]; then + echo -e "\tdns_search $(eval echo \$NET4_NS_SEARCH_$iface)" >> $if_file + fi - elif [[ $(eval echo \$NET4_MODE_$iface) == dhcp ]]; then - prnt I "Configuring IPv4 network interface $iface in DHCP mode..." - echo "auto $iface" >> $if_file - echo "iface $iface inet dhcp" >> $if_file + elif [[ $(eval echo \$NET4_MODE_$iface) == dhcp ]]; then + prnt I "Configuring IPv4 network interface $iface in DHCP mode..." + echo "auto $iface" >> $if_file + echo "iface $iface inet dhcp" >> $if_file - elif [[ $(eval echo \$NET4_MODE_$iface) == manual ]]; then - local fname=$(eval echo \$NET4_MANUAL_FILE_$iface) - append_file $fname $if_file - unset fname - fi + elif [[ $(eval echo \$NET4_MODE_$iface) == manual ]]; then + local fname=$(eval echo \$NET4_MANUAL_FILE_$iface) + append_file $fname $if_file + unset fname + fi done for iface in $IPV6_IFACES; do - echo -e "\n# --------------------------------\n" >> $if_file + echo -e "\n# --------------------------------\n" >> $if_file - if [[ $(eval echo \$NET6_MODE_$iface) == static ]]; then - prnt I "Configuring IPv6 network interface $iface in static mode..." - echo "auto $iface" >> $if_file - echo "iface $iface inet6 static" >> $if_file - echo -e "\taddress $(eval echo \$NET6_IP_$iface)" >> $if_file + if [[ $(eval echo \$NET6_MODE_$iface) == static ]]; then + prnt I "Configuring IPv6 network interface $iface in static mode..." + echo "auto $iface" >> $if_file + echo "iface $iface inet6 static" >> $if_file + echo -e "\taddress $(eval echo \$NET6_IP_$iface)" >> $if_file - if [[ -n $(eval echo \$NET6_GW_$iface) ]]; then - echo -e "\tgateway $(eval echo \$NET6_GW_$iface)" >> $if_file - fi + if [[ -n $(eval echo \$NET6_GW_$iface) ]]; then + echo -e "\tgateway $(eval echo \$NET6_GW_$iface)" >> $if_file + fi - if [[ -n $(eval echo \$NET6_NS_$iface) ]]; then - echo -e "\tdns_nameservers $(eval echo \$NET6_NS_$iface)" >> $if_file - fi + if [[ -n $(eval echo \$NET6_NS_$iface) ]]; then + echo -e "\tdns_nameservers $(eval echo \$NET6_NS_$iface)" >> $if_file + fi - if [[ -n $(eval echo \$NET6_NS_SEARCH_$iface) ]]; then - echo -e "\tdns_search $(eval echo \$NET6_NS_SEARCH_$iface)" >> $if_file - fi + if [[ -n $(eval echo \$NET6_NS_SEARCH_$iface) ]]; then + echo -e "\tdns_search $(eval echo \$NET6_NS_SEARCH_$iface)" >> $if_file + fi - elif [[ $(eval echo \$NET6_MODE_$iface) == dhcp ]]; then - prnt I "Configuring IPv6 network interface $iface in DHCP mode..." - echo "auto $iface" >> $if_file - echo "iface $iface inet6 dhcp" >> $if_file + elif [[ $(eval echo \$NET6_MODE_$iface) == dhcp ]]; then + prnt I "Configuring IPv6 network interface $iface in DHCP mode..." + echo "auto $iface" >> $if_file + echo "iface $iface inet6 dhcp" >> $if_file - elif [[ $(eval echo \$NET6_MODE_$iface) == manual ]]; then - local fname=$(eval echo \$NET6_MANUAL_FILE_$iface) - append_file $fname $if_file - unset fname - fi + elif [[ $(eval echo \$NET6_MODE_$iface) == manual ]]; then + local fname=$(eval echo \$NET6_MANUAL_FILE_$iface) + append_file $fname $if_file + unset fname + fi done unset iface if_file @@ -108,80 +108,80 @@ precheck_conf_network() { file_must_exists interfaces.head if [[ -z $IPV4_IFACES ]]; then - prnt W "No IPv4 interfaces to configure." + prnt W "No IPv4 interfaces to configure." else - for iface in $IPV4_IFACES; do - if [[ ! -d /sys/class/net/$iface ]]; then - prnt E "The iface $iface, asked to configure, do not exist!" - die 175 - 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 - fi - if [[ -z $(eval echo \$NET4_MODE_$iface) ]]; then - prnt E "Interfaces $iface have no mode set!" - die 175 - else - case $(eval echo \$NET4_MODE_$iface) in - "static") - if [[ -z $(eval echo \$NET4_IP_$iface) ]]; then - prnt E "No IPv4 have been assigned to static interface $iface!" - fi - prnt m " * Interface $iface will have $(eval echo \$NET4_IP_$iface) static IPv4 address." - ;; - "dhcp") - prnt m " * Interface $iface will use DHCP." - ;; - "manual") - file_must_exists $(eval echo \$NET4_MANUAL_FILE_$iface) - prnt m " * Interface $iface will use manual IPv4 configuration in a file." - ;; - *) - prnt E "Interfaces mode \"$(eval echo \$NET4_MODE_$iface)\" unsuported!" - die 175 - ;; - esac - fi - done + for iface in $IPV4_IFACES; do + if [[ ! -d /sys/class/net/$iface ]]; then + prnt E "The iface $iface, asked to configure, do not exist!" + die 175 + 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 + fi + if [[ -z $(eval echo \$NET4_MODE_$iface) ]]; then + prnt E "Interfaces $iface have no mode set!" + die 175 + else + case $(eval echo \$NET4_MODE_$iface) in + "static") + if [[ -z $(eval echo \$NET4_IP_$iface) ]]; then + prnt E "No IPv4 have been assigned to static interface $iface!" + fi + prnt m " * Interface $iface will have $(eval echo \$NET4_IP_$iface) static IPv4 address." + ;; + "dhcp") + prnt m " * Interface $iface will use DHCP." + ;; + "manual") + file_must_exists $(eval echo \$NET4_MANUAL_FILE_$iface) + prnt m " * Interface $iface will use manual IPv4 configuration in a file." + ;; + *) + prnt E "Interfaces mode \"$(eval echo \$NET4_MODE_$iface)\" unsuported!" + die 175 + ;; + esac + fi + done fi if [[ -z $IPV6_IFACES ]]; then - prnt W "No IPv6 interfaces to configure." + prnt W "No IPv6 interfaces to configure." else - for iface in $IPV6_IFACES; do - if [[ ! -d /sys/class/net/$iface ]]; then - prnt E "The iface $iface, asked to configure, do not exist!" - die 175 - else - if [[ $(grep "up" /sys/class/net/$iface/operstate) ]]; then - prnt W "The IPv6 iface $iface, is already configured, a reboot will be required." - fi - fi - if [[ -z $(eval echo \$NET6_MODE_$iface) ]]; then - prnt E "Interfaces $iface have no mode set!" - die 175 - else - case $(eval echo \$NET6_MODE_$iface) in - "static") - if [[ -z $(eval echo \$NET6_IP_$iface) ]]; then - prnt E "No IPv6 have been assigned to static interface $iface!" - fi - prnt m " * Interface $iface will have $(eval echo \$NET6_IP_$iface) static IPv6 address." - ;; - "dhcp") - prnt m " * Interface $iface will use DHCPv6." - ;; - "manual") - file_must_exists $(eval echo \$NET6_MANUAL_FILE_$iface) - prnt m " * Interface $iface will use manual IPv6 configuration in a file." - ;; - *) - prnt E "Interfaces mode \"$(eval echo \$NET6_MODE_$iface)\" unsuported!" - die 175 - ;; - esac - fi - done + for iface in $IPV6_IFACES; do + if [[ ! -d /sys/class/net/$iface ]]; then + prnt E "The iface $iface, asked to configure, do not exist!" + die 175 + else + if [[ $(grep "up" /sys/class/net/$iface/operstate) ]]; then + prnt W "The IPv6 iface $iface, is already configured, a reboot will be required." + fi + fi + if [[ -z $(eval echo \$NET6_MODE_$iface) ]]; then + prnt E "Interfaces $iface have no mode set!" + die 175 + else + case $(eval echo \$NET6_MODE_$iface) in + "static") + if [[ -z $(eval echo \$NET6_IP_$iface) ]]; then + prnt E "No IPv6 have been assigned to static interface $iface!" + fi + prnt m " * Interface $iface will have $(eval echo \$NET6_IP_$iface) static IPv6 address." + ;; + "dhcp") + prnt m " * Interface $iface will use DHCPv6." + ;; + "manual") + file_must_exists $(eval echo \$NET6_MANUAL_FILE_$iface) + prnt m " * Interface $iface will use manual IPv6 configuration in a file." + ;; + *) + prnt E "Interfaces mode \"$(eval echo \$NET6_MODE_$iface)\" unsuported!" + die 175 + ;; + esac + fi + done fi } diff --git a/modules/conf_ntp.sh b/modules/conf_ntp.sh index c987240..64b76a0 100644 --- a/modules/conf_ntp.sh +++ b/modules/conf_ntp.sh @@ -17,8 +17,8 @@ export DEP_conf_ntp="" conf_ntp() { if [[ $(pidof systemd) ]]; then - prnt I "Disabling Systemd-timesyncd..." - systemctl disable systemd-timesyncd || true + prnt I "Disabling Systemd-timesyncd..." + systemctl disable systemd-timesyncd || true fi prnt I "Installing ntp daemon..." @@ -33,11 +33,11 @@ conf_ntp() install_file ntp.conf $dest local line="" for srv in $NTP_SERVERS; do - line="${line}server $srv iburst\n" + line="${line}server $srv iburst\n" done sed -i -e "s/@SERVERLIST@/$line/" $dest && - echo "# Generated on $(stdtime)" >> $dest && - mv -fv $dest /etc/ntp.conf + echo "# Generated on $(stdtime)" >> $dest && + mv -fv $dest /etc/ntp.conf prnt I "Starting service ntp..." svc_start ntp @@ -49,14 +49,14 @@ conf_ntp() precheck_conf_ntp() { if [[ -z $NTP_SERVERS ]]; then - prnt E "No configured NTP server!" - die 151 + prnt E "No configured NTP server!" + die 151 else - file_must_exists ntp.conf - prnt m "The NTP servers to be used will be:" - for srv in $NTP_SERVERS; do - prnt m " * $srv" - done + file_must_exists ntp.conf + prnt m "The NTP servers to be used will be:" + for srv in $NTP_SERVERS; do + prnt m " * $srv" + done fi } diff --git a/modules/conf_ssh.sh b/modules/conf_ssh.sh index c8db509..48b9740 100644 --- a/modules/conf_ssh.sh +++ b/modules/conf_ssh.sh @@ -24,9 +24,9 @@ conf_ssh() prnt I "Installating OpenSSH configuration files..." for f in /etc/ssh/ssh{,d}_config; do - backup_dist $f - install_file ssh/$(basename $f) $f - tag_file $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 diff --git a/modules/create_vm.sh b/modules/create_vm.sh index 0d563d4..a21085a 100644 --- a/modules/create_vm.sh +++ b/modules/create_vm.sh @@ -17,8 +17,8 @@ export DEP_create_vm="upgrade_dist install_pkg" create_vm() { if [[ $WITH_VM != "yes" ]]; then - prnt W "That computer is not configured for virtualisation, nothing to do." - return 0 + prnt W "That computer is not configured for virtualisation, nothing to do." + return 0 fi pkginst virtualbox @@ -32,60 +32,60 @@ create_vm() local accel_2d=off case $VM_OS in - Windows*) - accel_2d=on - ;; + Windows*) + accel_2d=on + ;; esac # Create emty VM local targetdir=$VM_ROOT/vms/$VM_NAME vboxmanage createvm --ostype $VM_OS --basefolder $targetdir \ - --name $VM_NAME --register + --name $VM_NAME --register # Give main caracteristics vboxmanage modifyvm $VM_NAME \ - --cpus $VM_CPU --memory $VM_MEM --vram $VM_VID_MEM \ - --boot1 $VM_BOOT1 --VM_BOOT2 $VM_BOOT2 --boot3 $VM_BOOT3 \ - --nic1 bridged --bridgeadapter1 $VM_IF_BRIDGE \ - --accelerate2dvideo $accel_2d \ - --clipboard bidirectional --draganddrop disabled + --cpus $VM_CPU --memory $VM_MEM --vram $VM_VID_MEM \ + --boot1 $VM_BOOT1 --VM_BOOT2 $VM_BOOT2 --boot3 $VM_BOOT3 \ + --nic1 bridged --bridgeadapter1 $VM_IF_BRIDGE \ + --accelerate2dvideo $accel_2d \ + --clipboard bidirectional --draganddrop disabled # Add a SATA controler vboxmanage storagectl $VM_NAME \ - --name sata0 --add sata --controller IntelAHCI --bootable on \ - --hostiocache on --portcount 6 + --name sata0 --add sata --controller IntelAHCI --bootable on \ + --hostiocache on --portcount 6 # Create a virtual HDD vboxmanage createmedium \ - --size $VM_DISK_SIZE --variant Fixed --filename $targetdir/$VM_NAME.vdi + --size $VM_DISK_SIZE --variant Fixed --filename $targetdir/$VM_NAME.vdi # Connect the created HDD to the VM vboxmanage storageattach $VM_NAME \ - --storagectl sata0 --port 1 --device 0 --type hdd \ - --medium $targetdir/$VM_NAME.vdi + --storagectl sata0 --port 1 --device 0 --type hdd \ + --medium $targetdir/$VM_NAME.vdi unset targetdir accel_2d # Add empty DVD vboxmanage storageattach $VM_NAME --storagectl sata0 --port 2 --device 0 \ - --medium emptydrive + --medium emptydrive # Add shares local share= i=0 for share in $VM_SHARES_NAME; do - (( i+=1 )) + (( i+=1 )) - local j=0 hostpath="" - for path in $VM_SHARES_PATH; do - (( j+=1 )) - if [[ $i -eq $j ]]; then - hostpath=$path - fi - done - unset j + local j=0 hostpath="" + for path in $VM_SHARES_PATH; do + (( j+=1 )) + if [[ $i -eq $j ]]; then + hostpath=$path + fi + done + unset j - vboxmanage sharedfolder add $VM_NAME \ - --name ${VM_SHARES_NAME,,} --hostpath $hostpath + vboxmanage sharedfolder add $VM_NAME \ + --name ${VM_SHARES_NAME,,} --hostpath $hostpath done unset share i } @@ -93,35 +93,35 @@ create_vm() precheck_create_vm() { if [[ $WITH_VM == "yes" ]]; then - if [[ -z $VM_NAME ]]; then - prnt E "The virtual machine must have a name." - die 181 - fi - if [[ -z VM_CPU || -z VM_MEM || -z VM_OS || -z VM_ROOT || \ - -z VM_BOOT1 || -z VM_BOOT2 || -z VM_BOOT3 || -z VM_VID_MEM || - -z VM_IF_BRIDGE || -z VM_DISK_SIZE ]]; then - prnt E "A necessary declaration for the virtual machine is absent!" - die 181 - else - prnt I "The virtual machine \"$VM_NAME\" will be created in $VM_ROOT..." - fi + if [[ -z $VM_NAME ]]; then + prnt E "The virtual machine must have a name." + die 181 + fi + if [[ -z VM_CPU || -z VM_MEM || -z VM_OS || -z VM_ROOT || \ + -z VM_BOOT1 || -z VM_BOOT2 || -z VM_BOOT3 || -z VM_VID_MEM || + -z VM_IF_BRIDGE || -z VM_DISK_SIZE ]]; then + prnt E "A necessary declaration for the virtual machine is absent!" + die 181 + else + prnt I "The virtual machine \"$VM_NAME\" will be created in $VM_ROOT..." + fi - local share= i=0 j=0 - for share in $VM_SHARES_NAME; do - (( i+=1 )) - done - for share in $VM_SHARES_PATH; do - (( j+=1 )) - done - unset share - if [[ $i -eq $j ]]; then - prnt I "The virtual machine will access $i directories from the host." - else - prnt E "The number of share and path to share is different!" - die 182 - fi + local share= i=0 j=0 + for share in $VM_SHARES_NAME; do + (( i+=1 )) + done + for share in $VM_SHARES_PATH; do + (( j+=1 )) + done + unset share + if [[ $i -eq $j ]]; then + prnt I "The virtual machine will access $i directories from the host." + else + prnt E "The number of share and path to share is different!" + die 182 + fi else - prnt I "No virtual machine to create." + prnt I "No virtual machine to create." fi } diff --git a/modules/install_chromium.sh b/modules/install_chromium.sh index 453ea83..a744461 100644 --- a/modules/install_chromium.sh +++ b/modules/install_chromium.sh @@ -20,18 +20,18 @@ install_chromium() { # Add Debian repo to sources.list.d directory depending on Ubuntu version case $SYS_VER in - 16.04|16.10|17.04|17.10) - prnt I "Adding Debian Stretch repository to software sources..." - install_file debian_stretch.list /etc/apt/sources.list.d/ - ;; - 18.04|18.10|19.04|19.10) - prnt I "Adding Debian Buster repository to software sources..." - install_file debian_buster.list /etc/apt/sources.list.d/ - ;; - 20.04|20.10|21.04|21.10) - prnt I "Adding Debian Bullseye repository to software sources..." - install_file debian_bullseye.list /etc/apt/sources.list.d/ - ;; + 16.04|16.10|17.04|17.10) + prnt I "Adding Debian Stretch repository to software sources..." + install_file debian_stretch.list /etc/apt/sources.list.d/ + ;; + 18.04|18.10|19.04|19.10) + prnt I "Adding Debian Buster repository to software sources..." + install_file debian_buster.list /etc/apt/sources.list.d/ + ;; + 20.04|20.10|21.04|21.10) + prnt I "Adding Debian Bullseye repository to software sources..." + install_file debian_bullseye.list /etc/apt/sources.list.d/ + ;; esac # Install Debian GPG keys @@ -56,23 +56,23 @@ precheck_install_chromium() { # Check we run Ubuntu if [[ $SYS_DIST != "ubuntu" ]]; then - prnt E "The install_chromium module is a Ubuntu only workaround." - die 165 + prnt E "The install_chromium module is a Ubuntu only workaround." + die 165 fi case $SYS_VER in - 16.04|16.10|17.04|17.10) - prnt m " * Detected Ubuntu $SYS_VER, will install Stretch version of Chromium" - ;; - 18.04|18.10|19.04|19.10) - prnt m " * Detected Ubuntu $SYS_VER, will install Buster version of Chromium" - ;; - 20.04|20.10|21.04|21.10) - prnt m " * Detected Ubuntu $SYS_VER, will install Bullseye version of Chromium" - ;; - *) - prnt E "Unable to determine the corresponding Debian version." - die 165 - ;; + 16.04|16.10|17.04|17.10) + prnt m " * Detected Ubuntu $SYS_VER, will install Stretch version of Chromium" + ;; + 18.04|18.10|19.04|19.10) + prnt m " * Detected Ubuntu $SYS_VER, will install Buster version of Chromium" + ;; + 20.04|20.10|21.04|21.10) + prnt m " * Detected Ubuntu $SYS_VER, will install Bullseye version of Chromium" + ;; + *) + prnt E "Unable to determine the corresponding Debian version." + die 165 + ;; esac } diff --git a/modules/install_desktop.sh b/modules/install_desktop.sh index a3d2940..3dbc284 100644 --- a/modules/install_desktop.sh +++ b/modules/install_desktop.sh @@ -21,12 +21,12 @@ export DEP_install_desktop="upgrade_dist" install_desktop() { if [[ -n $X11_DRV ]]; then - prnt I "Installing additionnal X11 drivers..." - pkginst $X11_DRV + prnt I "Installing additionnal X11 drivers..." + pkginst $X11_DRV fi if [[ $UBUNTU_FLAVOR ]]; then - prnt I "Installing $UBUNTU_FLAVOR environment..." - pkginst ${UBUNTU_FLAVOR}-desktop + prnt I "Installing $UBUNTU_FLAVOR environment..." + pkginst ${UBUNTU_FLAVOR}-desktop fi # Because we're lazy but manual actions can avoid reboot... NEED_REBOOT=true @@ -35,12 +35,12 @@ install_desktop() precheck_install_desktop() { if [[ -z $UBUNTU_FLAVOR ]]; then - prnt W "No Ubuntu flavor chosen, no desktop environment will be installed!" + prnt W "No Ubuntu flavor chosen, no desktop environment will be installed!" else - prnt m " * The flavor $UBUNTU_FLAVOR will be installed..." + prnt m " * The flavor $UBUNTU_FLAVOR will be installed..." fi if [[ -n $X11_DRV ]]; then - prnt W "Non free drivers will be installed." + prnt W "Non free drivers will be installed." fi } diff --git a/modules/install_mkagent.sh b/modules/install_mkagent.sh index b8c41b8..12e0dbc 100644 --- a/modules/install_mkagent.sh +++ b/modules/install_mkagent.sh @@ -35,16 +35,16 @@ install_mkagent() precheck_install_mkagent() { if [[ -z $MK_VERSION ]]; then - prnt E "Undeclared check_mk version of the agent to install." - die 162 + prnt E "Undeclared check_mk version of the agent to install." + die 162 fi if [[ -z $MK_URL ]]; then - prnt E "Undeclared check_mk download URL." - die 162 + prnt E "Undeclared check_mk download URL." + die 162 fi if [[ -z $MK_SERVER_IP ]]; then - prnt E "Undeclared check_mk server." - die 162 + prnt E "Undeclared check_mk server." + die 162 fi file_must_exists cmk/check_mk cmk/mk_apt } diff --git a/modules/install_pkg.sh b/modules/install_pkg.sh index 9735b17..1365689 100644 --- a/modules/install_pkg.sh +++ b/modules/install_pkg.sh @@ -20,28 +20,28 @@ install_pkg() { # Remove unnecessary packages if [[ -n $PKGS_RMLIST ]]; then - prnt I "Removing some undesired packages..." - pkgrm $PKGS_RMLIST + prnt I "Removing some undesired packages..." + pkgrm $PKGS_RMLIST fi # Blacklist some anoying packages (and remove them if needed) 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 - install_file pkgman/blacklist.conf $dest && - sed -i -e "s/@pkg@/pkg/" $dest - tag_file $dest + for pkg in $PKGS_BLACKLIST; do + prnt I "Placing $pkg into the blacklist..." + local dest=/etc/apt/preferences.d/blacklist_$pkg + install_file pkgman/blacklist.conf $dest && + sed -i -e "s/@pkg@/pkg/" $dest + tag_file $dest - # If blacklisted we suppose uninstall as well (if neeeded) - pkgrm $pkg - done + # If blacklisted we suppose uninstall as well (if neeeded) + pkgrm $pkg + done fi # Install all the configured packages if [[ -n $PKGSEL ]]; then - prnt I "Installing the package selection..." - pkginst $PKGSEL + prnt I "Installing the package selection..." + pkginst $PKGSEL fi # Cleaning @@ -52,22 +52,22 @@ install_pkg() precheck_install_pkg() { if [[ -z PKGS_RMLIST ]]; then - prnt m " * No package to remove." + prnt m " * No package to remove." else - prnt m " * $(echo $PKGS_RMLIST | wc -w) package to remove." + prnt m " * $(echo $PKGS_RMLIST | wc -w) package to remove." fi if [[ -z PKGS_BLACKLIST ]]; then - prnt m " * The packages $pkg will be placed into the blacklist !" - file_must_exists pkgman/blacklist.conf + prnt m " * The packages $pkg will be placed into the blacklist !" + file_must_exists pkgman/blacklist.conf else - prnt m " * No package to blacklist." + prnt m " * No package to blacklist." fi if [[ -z $PKGSEL ]]; then - prnt m " * No additionnal package to install !" + prnt m " * No additionnal package to install !" else - prnt m " * $(echo $PKGSEL | wc -w) additionnal package have to be installed." + prnt m " * $(echo $PKGSEL | wc -w) additionnal package have to be installed." fi } diff --git a/modules/install_profile.sh b/modules/install_profile.sh index 043d569..ff79c92 100644 --- a/modules/install_profile.sh +++ b/modules/install_profile.sh @@ -18,16 +18,16 @@ install_profile() local usrlist="/root" if find /home -mindepth 1 -maxdepth 1 -type d | read; then - usrlist="$usrlist /home/*" + usrlist="$usrlist /home/*" fi for usr in $usrlist; do - prnt I "Installing profile for user $usr..." - 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} + prnt I "Installing profile for user $usr..." + 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 diff --git a/modules/patch_snmp.sh b/modules/patch_snmp.sh index 87cb578..6a3cc30 100644 --- a/modules/patch_snmp.sh +++ b/modules/patch_snmp.sh @@ -16,21 +16,21 @@ patch_snmp() pkginst snmpd prnt I "Configuring SNMP daemon..." backup_dist /etc/snmp/snmpd.conf /etc/default/snmpd \ - /lib/systemd/system/snmpd.service /etc/init.d/snmpd + /lib/systemd/system/snmpd.service /etc/init.d/snmpd install_file snmpd/snmpd.conf /etc/snmp/snmpd.conf tag_file /etc/snmp/snmpd.conf # No longer required with Debian >= 11 or Devuan >= 4 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 + ($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 - install_file snmpd/snmpd.service /lib/systemd/system/snmpd.service - if command -v systemctl &> /dev/null; then - systemctl daemon-reload - fi + install_file snmpd/snmpd.service /lib/systemd/system/snmpd.service + if command -v systemctl &> /dev/null; then + systemctl daemon-reload + fi fi svc_restart snmpd } @@ -39,7 +39,7 @@ precheck_patch_snmp() { file_must_exists snmpd/snmpd.{conf,default} if [[ -e /lib/systemd/system/snmpd.service ]]; then - file_must_exists snmpd/snmpd.service + file_must_exists snmpd/snmpd.service fi } diff --git a/modules/upgrade_dist.sh b/modules/upgrade_dist.sh index 9d14020..45142e8 100644 --- a/modules/upgrade_dist.sh +++ b/modules/upgrade_dist.sh @@ -36,19 +36,19 @@ upgrade_dist() prnt I "Configuring proxy for APT..." if [[ -n $PROXY_APT ]]; then - if [[ ! -d $(dirname $proxyfile) ]]; then - mkdir -pv $(dirname $proxyfile) || ( - prnt E "Impossible to create directory to receive APT configuration." - die 60 - ) - fi - tag_file $proxyfile - echo "Acquire::http::Proxy \"http://${PROXY_APT}:${PROXY_APT_PORT}\";" >> $proxyfile + if [[ ! -d $(dirname $proxyfile) ]]; then + mkdir -pv $(dirname $proxyfile) || ( + prnt E "Impossible to create directory to receive APT configuration." + die 60 + ) + fi + tag_file $proxyfile + echo "Acquire::http::Proxy \"http://${PROXY_APT}:${PROXY_APT_PORT}\";" >> $proxyfile elif [[ -n $PROXY_SRV ]]; then - tag_file $proxyfile - echo "Acquire::http::Proxy \"http://${PROXY_SRV}:${PROXY_SRV_PORT}\";" >> $proxyfile + tag_file $proxyfile + echo "Acquire::http::Proxy \"http://${PROXY_SRV}:${PROXY_SRV_PORT}\";" >> $proxyfile else - prnt I "No proxy configured, nothing to do." + prnt I "No proxy configured, nothing to do." fi # Remplace source.list from dist with ours (be smarter) @@ -69,16 +69,16 @@ precheck_upgrade_dist() prnt I "Checking network connectivity..." if [[ $(noerror wget -q --tries=10 --timeout=20 --spider http://www.tetaneutral.net) != 0 ]]; then - prnt E "It seems network configuration is not functionnal! Giving up." - die 160 + prnt E "It seems network configuration is not functionnal! Giving up." + die 160 fi if [[ -n $PROXY_APT && -z $PROXY_APT_PORT ]]; then - prnt E "An APT proxy server have been specified but not its working port." - die 160 + prnt E "An APT proxy server have been specified but not its working port." + die 160 fi if [[ -n $PROXY_SRV && -z $PROXY_SRV_PORT ]]; then - prnt E "A general proxy server have been specified but not its working port." - die 160 + prnt E "A general proxy server have been specified but not its working port." + die 160 fi file_must_exists pkgman/${SYS_DIST}_${SYS_VER}.list }