improved code quality, few bug fixes
This commit is contained in:
@@ -19,12 +19,12 @@ export REMOVE_USERS="fatal"
|
||||
export NTP_SERVERS="didicas.$REALM cagua.$REALM"
|
||||
|
||||
# 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_pinatubo="192.168.1.253"
|
||||
export CEPHIP_ragang="192.168.1.252"
|
||||
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 SHARED_HOME="false"
|
||||
|
||||
|
||||
50
init.sh
50
init.sh
@@ -36,10 +36,10 @@ export LC_ALL=C
|
||||
export LANG=C
|
||||
|
||||
# Version of init
|
||||
export VERSION="0.99.19"
|
||||
export VERSION="0.99.20"
|
||||
|
||||
# Store script's path (realpath -s resolve symlinks if init.sh is a symlink)
|
||||
export MYPATH=$(dirname $(realpath -s $0))
|
||||
export MYPATH=$(dirname $(realpath -s "$0"))
|
||||
|
||||
# Get hostname
|
||||
export HOSTNAME=$(hostname)
|
||||
@@ -65,7 +65,7 @@ function_exists prnt || (
|
||||
# ==== Main Program ====
|
||||
# ======================
|
||||
|
||||
# Set system dependent vars (OS, distro and version)
|
||||
# Set system dependent vars (arch, OS, distro and version)
|
||||
set_sys_vars $(uname -m) $(get_os_version)
|
||||
|
||||
# Initializing global variables
|
||||
@@ -84,22 +84,22 @@ check_root
|
||||
# ------------------------------------------------------------------------------
|
||||
# Logfile variable treatment -- cannot be a function
|
||||
|
||||
if [[ -n $NEW_LOGFILE ]]; then
|
||||
export LOGFILE=$NEW_LOGFILE
|
||||
if [[ -n "$NEW_LOGFILE" ]]; then
|
||||
export LOGFILE="$NEW_LOGFILE"
|
||||
else
|
||||
export LOGFILE=${LOGFILE:-"$MYPATH/log/init-$(uname -n)-$(stdtime).log"}
|
||||
fi
|
||||
|
||||
prnt I "Creating log files welcoming directory..."
|
||||
if [[ ! -d $(dirname $LOGFILE) ]]; then
|
||||
mkdir -pv $(dirname $LOGFILE)
|
||||
if [[ ! -d $(dirname "$LOGFILE") ]]; then
|
||||
mkdir -pv $(dirname "$LOGFILE")
|
||||
fi
|
||||
|
||||
# Log all outputs to the logfile
|
||||
exec 3>&1 4>&2
|
||||
trap 'exec 2>&4 1>&3' 0 1 2 3
|
||||
exec > >(tee -a $LOGFILE)
|
||||
exec 2> >(tee -a $LOGFILE >&2)
|
||||
exec > >(tee -a "$LOGFILE")
|
||||
exec 2> >(tee -a "$LOGFILE" >&2)
|
||||
prnt I "Starting init.sh version $VERSION."
|
||||
prnt I "The log file is $LOGFILE."
|
||||
if [[ -n $SYS_CODE ]]; then
|
||||
@@ -113,7 +113,7 @@ fi
|
||||
|
||||
separator
|
||||
|
||||
if [[ -n $CHROOT_PATH && -z $CHROOT_DONE ]]; then
|
||||
if [[ -n "$CHROOT_PATH" && -z $CHROOT_DONE ]]; then
|
||||
chroot_bootstrap $@
|
||||
prnt I "Normal end of chrooted execution!"
|
||||
exit 0
|
||||
@@ -139,7 +139,7 @@ separator
|
||||
|
||||
if [[ $RUN_SHELL == true ]]; then
|
||||
prnt I "Launching an interactive shell..."
|
||||
bash --rcfile $MYPATH/bash.rc -i
|
||||
bash --rcfile "$MYPATH/bash.rc" -i
|
||||
prnt I "Script execution terminated after interactive shell execution."
|
||||
exit 0
|
||||
fi
|
||||
@@ -165,8 +165,8 @@ if ! command -v wget &> /dev/null; then
|
||||
fi
|
||||
|
||||
# Run prechecks
|
||||
if [[ JUMP != true ]]; then
|
||||
tmpfile=$(mktemp /tmp/init-XXXXXX)
|
||||
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."
|
||||
fi
|
||||
@@ -174,11 +174,11 @@ if [[ JUMP != true ]]; then
|
||||
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
|
||||
if [[ $RESUME == true ]] && [[ $(grep $mod "$STAGE_FILE") ]]; then
|
||||
prnt I "Checks previously executed for $mod version ${!version}."
|
||||
continue
|
||||
fi
|
||||
@@ -186,7 +186,7 @@ if [[ JUMP != true ]]; then
|
||||
if [[ -z $MANUAL_MODULE_LIST && $NO_DEPS != true ]]; then
|
||||
deps=DEP_$mod
|
||||
for dep in ${!deps}; do
|
||||
if [[ ! $(grep $dep $tmpfile) ]]; then
|
||||
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
|
||||
@@ -198,9 +198,9 @@ if [[ JUMP != true ]]; then
|
||||
(
|
||||
precheck_$mod
|
||||
)
|
||||
echo $mod >> $tmpfile
|
||||
echo $mod >> "$tmpfile"
|
||||
done
|
||||
rm -f $tmpfile
|
||||
rm -f "$tmpfile"
|
||||
unset mod
|
||||
fi
|
||||
|
||||
@@ -234,12 +234,12 @@ echo && separator && echo
|
||||
if [[ $key == "C" || $key == 'c' ]]; then
|
||||
# Reinit stage file if no resuming
|
||||
if [[ $RESUME != true ]] && [[ -f $STAGE_FILE ]]; then
|
||||
rm -f $STAGE_FILE
|
||||
rm -f "$STAGE_FILE"
|
||||
fi
|
||||
|
||||
# We launch modules one after one
|
||||
for mod in $MODULE_LIST; do
|
||||
if [[ $RESUME == true ]] && [[ $(grep $mod $STAGE_FILE) ]]; then
|
||||
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
|
||||
@@ -250,9 +250,9 @@ if [[ $key == "C" || $key == 'c' ]]; then
|
||||
export REBOOT_NEEDED=false
|
||||
$mod
|
||||
if [[ $REBOOT_NEEDED == true ]]; then
|
||||
echo "$mod reboot" >> $STAGE_FILE # Mark as done for resuming
|
||||
echo "$mod reboot" >> "$STAGE_FILE" # Mark as done for resuming
|
||||
else
|
||||
echo $mod >> $STAGE_FILE # Mark as done for resuming function
|
||||
echo "$mod" >> "$STAGE_FILE" # Mark as done for resuming function
|
||||
fi
|
||||
)
|
||||
separator
|
||||
@@ -265,15 +265,15 @@ fi
|
||||
prnt I "That's all folks !"
|
||||
echo
|
||||
|
||||
if [[ -s $STAGE_FILE && $(grep " reboot" $STAGE_FILE) ]]; then
|
||||
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 | \
|
||||
prnt m " * $(grep ' reboot' "$STAGE_FILE" | \
|
||||
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
|
||||
|
||||
rm -f $STAGEFILE
|
||||
rm -f "$STAGE_FILE"
|
||||
exit 0
|
||||
# EOF
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#!/bin/bash
|
||||
# ------------------------------------------------------------------------------
|
||||
# Error management functions
|
||||
# This file is part of the init.sh project
|
||||
@@ -29,7 +30,7 @@ function die()
|
||||
unset errorcode
|
||||
|
||||
# Put the trigger back (only executed with --keepgoing)
|
||||
trap "error ${LINENO}" ERR
|
||||
trap 'error ${LINENO}' ERR
|
||||
}
|
||||
export -f die
|
||||
|
||||
@@ -73,8 +74,8 @@ trap "error ${LINENO}; backtrace; err_exit" ERR
|
||||
function err_exit
|
||||
{
|
||||
if [[ $KEEPGOING != true ]]; then
|
||||
if [[ -f $tmpfile ]]; then
|
||||
rm -f $tmpfile
|
||||
if [[ -f "$tmpfile" ]]; then
|
||||
rm -f "$tmpfile"
|
||||
fi
|
||||
exit 255
|
||||
fi
|
||||
@@ -94,7 +95,7 @@ function backtrace
|
||||
printf '%15s() %s:%d\n' \
|
||||
"$func" "${BASH_SOURCE[$i]}" "${BASH_LINENO[ (( $i - 1)) ]}"
|
||||
fi
|
||||
let i++ || true
|
||||
(( i++ )) || true
|
||||
done
|
||||
unset func i
|
||||
echo "=============================="
|
||||
@@ -120,7 +121,7 @@ noerror()
|
||||
fi
|
||||
echo $?
|
||||
|
||||
trap "error ${LINENO}" ERR
|
||||
trap 'error ${LINENO}' ERR
|
||||
set -o errexit
|
||||
}
|
||||
export -f noerror
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#!/bin/bash
|
||||
# ------------------------------------------------------------------------------
|
||||
# Chroot system functions
|
||||
# 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
|
||||
chroot_bootstrap()
|
||||
{
|
||||
if [[ ! -d $CHROOT_PATH ]]; then
|
||||
if [[ ! -d "$CHROOT_PATH" ]]; then
|
||||
prnt E "The path given to chroot don't exists."
|
||||
die 14
|
||||
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."
|
||||
die 15
|
||||
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"
|
||||
if [[ $RESUME == true ]]; then
|
||||
bootstrap_items="$bootstrap_items $STAGE_FILE"
|
||||
fi
|
||||
|
||||
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..."
|
||||
# on the following line, true allows to correctly exit in case of error since
|
||||
# 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 [[ -e $tmpdir/$(basename $STAGE_FILE) ]]; then
|
||||
cp $tmpdir/$(basename $STAGE_FILE) $STAGE_FILE
|
||||
if [[ -e "$tmpdir/$(basename "$STAGE_FILE")" ]]; then
|
||||
cp "$tmpdir/$(basename "$STAGE_FILE")" "$STAGE_FILE"
|
||||
fi
|
||||
|
||||
prnt I "Back to host system and clean up."
|
||||
rm -rf $tmpdir
|
||||
rm -rf "$tmpdir"
|
||||
}
|
||||
|
||||
# EOF
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#!/bin/env bash
|
||||
# ------------------------------------------------------------------------------
|
||||
# Main program functions
|
||||
# This file is part of the init.sh project
|
||||
@@ -14,39 +15,46 @@
|
||||
# errors with immediate exit.
|
||||
read_commandline()
|
||||
{
|
||||
syntax_error()
|
||||
{
|
||||
prnt E "Error while analysing command line parameters."
|
||||
die 1 --force
|
||||
}
|
||||
|
||||
# Processing command line options
|
||||
local want_module=false
|
||||
local want_logfile=false
|
||||
local want_conffile=false
|
||||
local want_chroot=false
|
||||
local opt=
|
||||
for opt in $@; do
|
||||
case $opt in
|
||||
local params=''
|
||||
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")
|
||||
disp_help
|
||||
shift
|
||||
exit 0
|
||||
;;
|
||||
"-v"|"--version")
|
||||
show_version
|
||||
shift
|
||||
exit 0
|
||||
;;
|
||||
"-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")
|
||||
export CHECK_ONLY=true
|
||||
shift
|
||||
;;
|
||||
"-j"|"--jump")
|
||||
export JUMP=true
|
||||
shift
|
||||
;;
|
||||
"-k"|"--keep-going")
|
||||
export KEEPGOING=true
|
||||
shift
|
||||
;;
|
||||
"-r"|"--resume")
|
||||
if [[ -s $STAGE_FILE ]]; then
|
||||
@@ -56,91 +64,68 @@ read_commandline()
|
||||
prnt E "Without it, resuming is impossible."
|
||||
die 17 --force
|
||||
fi
|
||||
shift
|
||||
;;
|
||||
"-R"|"--no-root-check")
|
||||
export NO_ROOT_CHECK=true
|
||||
shift
|
||||
;;
|
||||
"-D"|"--no-deps")
|
||||
export NO_DEPS=true
|
||||
shift
|
||||
;;
|
||||
"-o"|"--offline")
|
||||
export OFFLINE=true
|
||||
shift
|
||||
;;
|
||||
"-P"|"--no-proxy")
|
||||
export NO_PROXY=true
|
||||
shift
|
||||
;;
|
||||
"-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
|
||||
export NEW_LOGFILE=$2
|
||||
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
|
||||
shift 2
|
||||
;;
|
||||
"-f"|"--file")
|
||||
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
|
||||
shift 2
|
||||
;;
|
||||
"-s"|"--shell")
|
||||
export RUN_SHELL=true
|
||||
shift
|
||||
;;
|
||||
"--chroot")
|
||||
if [[ -z $CHROOT_PATH ]]; then
|
||||
export CHROOT_PATH=$opt
|
||||
want_chroot=false
|
||||
export CHROOT_PATH=$2
|
||||
else
|
||||
prnt E "A chroot path have already been given."
|
||||
die 1 --force
|
||||
fi
|
||||
else
|
||||
prnt E "Unknow parameter \"$opt\"."
|
||||
die 1 --force
|
||||
shift 2
|
||||
;;
|
||||
"--cron")
|
||||
export CRON_MODE=true
|
||||
shift
|
||||
;;
|
||||
--)
|
||||
shift
|
||||
break
|
||||
;;
|
||||
*)
|
||||
if [[ -n $1 ]]; then
|
||||
prnt E "Unknow parameter \"$1\" !"
|
||||
die 1
|
||||
fi
|
||||
break
|
||||
;;
|
||||
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
|
||||
fi
|
||||
|
||||
unset want_conffile want_logfile want_module want_chroot
|
||||
}
|
||||
export -f read_commandline
|
||||
|
||||
@@ -180,11 +165,12 @@ process_commandline_and_vars()
|
||||
|
||||
# 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=${MANUAL_MODULE_LIST//,/ /g}
|
||||
prnt m " * $MODULE_LIST"
|
||||
fi
|
||||
|
||||
# Check for module list existance and basic syntax
|
||||
# Check for module list exis<tance and basic syntax
|
||||
if [[ -n $MODULE_LIST ]]; then
|
||||
for mod in $MODULE_LIST; do
|
||||
if [[ $mod =~ ['-!@#$%\&*=+'] ]]; then
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#!/bin/bash
|
||||
# ------------------------------------------------------------------------------
|
||||
# Disks and partitions manipulation function
|
||||
# This file is part of the init.sh project
|
||||
@@ -82,7 +83,7 @@ mkparts()
|
||||
local tmpfile=$(mktemp sfd.XXXX)
|
||||
if [[ -n $1 ]]; then
|
||||
# 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 [[ $part == 0 ]]; then
|
||||
echo ",,L" >> $tmpfile
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#!/bin/bash
|
||||
# ------------------------------------------------------------------------------
|
||||
# Some display functions and defines color codes
|
||||
# This file is part of the init.sh project
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#!/bin/bash
|
||||
# ------------------------------------------------------------------------------
|
||||
# File manipulation function
|
||||
# This file is part of the init.sh project
|
||||
@@ -34,7 +35,7 @@ backup_dist()
|
||||
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})
|
||||
backup_dist $(readlink -f "${file}")
|
||||
elif [[ -f ${file} ]]; then
|
||||
prnt I "Creating a backup of ${file} on $tmstmp..."
|
||||
cp -av $file ${file}.dist.${tmstmp}
|
||||
@@ -134,7 +135,7 @@ install_file()
|
||||
prnt E "install_file(): At least two arguments are required."
|
||||
die 11
|
||||
fi
|
||||
if [[ $(echo $@ | grep "\*\|\?") ]]; then
|
||||
if [[ -n $(echo $@ | grep "\*\|\?") ]]; then
|
||||
prnt E "install_file(): Wildcards are not authorized."
|
||||
die 7
|
||||
fi
|
||||
@@ -215,7 +216,7 @@ is_dir_empty()
|
||||
return 0
|
||||
fi
|
||||
|
||||
nbfiles=$(ls -a1 $dir | egrep -v '^.$|^..$' | wc -l)
|
||||
nbfiles=$(ls -a1 $dir | grep -Evc '^.$|^..$')
|
||||
if [[ $nbfiles -eq 0 ]]; then
|
||||
return 0
|
||||
fi
|
||||
@@ -240,7 +241,7 @@ patch_file()
|
||||
|
||||
# Create a sub-process, to avoid bash environment pollution
|
||||
(
|
||||
local varlist= pattern=
|
||||
local varlist='' pattern=''
|
||||
if [[ $# -eq 0 ]] ; then
|
||||
pattern="-e s/<\(.*\)>/\$\1\$\1/g"
|
||||
else
|
||||
@@ -249,7 +250,6 @@ patch_file()
|
||||
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
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#!/bin/bash
|
||||
# ------------------------------------------------------------------------------
|
||||
# Loaders for conf and prepost functions
|
||||
# This file is part of the init.sh project
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#!/bin/bash
|
||||
# ------------------------------------------------------------------------------
|
||||
# Network functions
|
||||
# This file is part of the init.sh project
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#!/bin/bash
|
||||
# ------------------------------------------------------------------------------
|
||||
# Package manager integration
|
||||
# This file is part of the init.sh project
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#!/bin/bash
|
||||
# ------------------------------------------------------------------------------
|
||||
# Services manipulation functions
|
||||
# This file is part of the init.sh project
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#!/bin/bash
|
||||
# ------------------------------------------------------------------------------
|
||||
# Base support function
|
||||
# This file is part of the init.sh project
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#!/bin/bash
|
||||
# ------------------------------------------------------------------------------
|
||||
# Various utilitary functions
|
||||
# This file is part of the init.sh project
|
||||
@@ -25,7 +26,7 @@ function_exists() {
|
||||
die 11 --force
|
||||
fi
|
||||
|
||||
if [[ $(LC_ALL=C type -t $1 | grep function) ]]; then
|
||||
if [[ -n $(LC_ALL=C type -t $1 | grep function) ]]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
@@ -42,7 +43,7 @@ get_mod_name()
|
||||
prnt E "get_mod_name(): Bad number of parameters."
|
||||
die 11 --force
|
||||
fi
|
||||
echo $(basename $1 | cut -f 1 -d '.')
|
||||
basename $1 | cut -f 1 -d '.'
|
||||
}
|
||||
export -f get_mod_name
|
||||
|
||||
@@ -52,7 +53,7 @@ export -f get_mod_name
|
||||
trim()
|
||||
{
|
||||
local string="$@"
|
||||
echo "$(sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//'<<<"${string}")"
|
||||
sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//'<<<"${string}"
|
||||
unset string
|
||||
}
|
||||
export -f trim
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#!/bin/bash
|
||||
# ------------------------------------------------------------------------------
|
||||
# Version determination function
|
||||
# This file is part of the init.sh project
|
||||
@@ -37,7 +38,7 @@ get_os_version()
|
||||
unset maj min
|
||||
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}')
|
||||
|
||||
|
||||
|
||||
@@ -20,22 +20,22 @@
|
||||
# * DEFAULT_SHELL: The shell to use when creating new users
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
export VER_authnz=0.2.2
|
||||
export VER_authnz="0.2.2"
|
||||
export DEP_authnz="upgrade_dist"
|
||||
|
||||
# Users (from Ldap)
|
||||
add_remote_user()
|
||||
{
|
||||
if [[ $(grep "^$1:" /etc/passwd) ]]; then
|
||||
if [[ -n $(grep "^$1:" /etc/passwd) ]]; then
|
||||
prnt W "A local user with name $1 already exists, adding anyway!"
|
||||
fi
|
||||
if [[ $(grep "^+$1:" /etc/passwd) ]]; then
|
||||
if [[ -n $(grep "^+$1:" /etc/passwd) ]]; then
|
||||
prnt W "The remote user $1 is already declared, nothing to do in passwd."
|
||||
else
|
||||
echo "+$1::::::" >> /etc/passwd
|
||||
prnt I "User $1 added to passwd..."
|
||||
fi
|
||||
if [[ $(grep "^+$1:" /etc/shadow) ]]; then
|
||||
if [[ -n $(grep "^+$1:" /etc/shadow) ]]; then
|
||||
prnt W "The remote user $1 is already connectable, nothing to do in shadow."
|
||||
else
|
||||
echo "+$1::::::::" >> /etc/shadow
|
||||
@@ -46,10 +46,10 @@ add_remote_user()
|
||||
# Remove users
|
||||
remove_user()
|
||||
{
|
||||
if [[ $(grep "^$1:" /etc/{passwd,shadow,group,gshadow}) ]]; then
|
||||
if [[ -n $(grep "^$1:" /etc/{passwd,shadow,group,gshadow}) ]]; then
|
||||
# Using sed is more universal than any distro commands - local case
|
||||
sed -i -e "/^$1:/d" /etc/{passwd,shadow,group,gshadow}
|
||||
elif [[ $(grep "^+$1:" /etc/{passwd,shadow,group,gshadow}) ]]; then
|
||||
elif [[ -n $(grep "^+$1:" /etc/{passwd,shadow,group,gshadow}) ]]; then
|
||||
# remote case
|
||||
sed -i -e "/^+$1:/d" /etc/{passwd,shadow,group,gshadow}
|
||||
else
|
||||
|
||||
@@ -37,7 +37,7 @@ conf_ceph()
|
||||
pkginst ceph-common
|
||||
|
||||
# hosts files required for Ceph bootstrap when DNS not yet started
|
||||
if [[ ! $(grep "# Ceph" /etc/hosts) ]]; then
|
||||
if [[ -z $(grep "# Ceph" /etc/hosts) ]]; then
|
||||
prnt I "Adding server list to /etc/hosts"
|
||||
backup_dist /etc/hosts
|
||||
tag_file /etc/hosts
|
||||
@@ -57,7 +57,7 @@ conf_ceph()
|
||||
fstabchanged=true
|
||||
echo >> /etc/fstab
|
||||
local srvlist=$(echo $CEPH_SRV_NAMES | sed "s/ /,/g")
|
||||
if [[ ! $(grep $srvlist /etc/fstab) ]]; then
|
||||
if [[ -z $(grep $srvlist /etc/fstab) ]]; then
|
||||
echo "# Ceph :" >> /etc/fstab
|
||||
echo "$srvlist:/ /srv/ceph ceph defaults,_netdev,name=admin,secret=$CEPH_SECRET 0 0" >> /etc/fstab
|
||||
else
|
||||
@@ -72,7 +72,7 @@ conf_ceph()
|
||||
prnt I "Adding Samba entries to /etc/fstab"
|
||||
fstabchanged=true
|
||||
echo >> /etc/fstab
|
||||
if [[ ! $(grep $SMBSRV /etc/fstab) ]]; then
|
||||
if [[ -z $(grep $SMBSRV /etc/fstab) ]]; then
|
||||
echo "# Samba:" >> /etc/fstab
|
||||
echo "//$SMBSRV/share /srv/ceph/share cifs defaults,_netdev,username=root,password= 0 0" >> /etc/fstab
|
||||
else
|
||||
@@ -83,7 +83,7 @@ conf_ceph()
|
||||
prnt E "Ceph status not understood, the next tasks will probably fail"
|
||||
fi
|
||||
if [[ $success == yes ]]; then
|
||||
if [[ ! $(grep "^/srv/ceph/share" /etc/fstab) ]]; then
|
||||
if [[ -z $(grep "^/srv/ceph/share" /etc/fstab) ]]; then
|
||||
fstabchanged=true
|
||||
echo "/srv/ceph/share /share none defaults,_netdev,bind 0 0" >> /etc/fstab
|
||||
if [[ $SHARED_HOME == 1 ]]; then
|
||||
@@ -101,10 +101,10 @@ conf_ceph()
|
||||
|
||||
# Mount Ceph volumes if required
|
||||
prnt I "Mounting ceph volumes"
|
||||
[[ ! $(mount | grep "on /srv/ceph") ]] && mount -v /srv/ceph || mount -v /srv/ceph/share
|
||||
[[ ! $(mount | grep "on /share") ]] && mount -v /share
|
||||
[[ -z $(mount | grep "on /srv/ceph") ]] && mount -v /srv/ceph || mount -v /srv/ceph/share
|
||||
[[ -z $(mount | grep "on /share") ]] && mount -v /share
|
||||
if [[ $SHARED_HOME == "true" ]]; then
|
||||
[[ ! $(mount | grep "on /home") ]] && mount -v /home
|
||||
[[ -z $(mount | grep "on /home") ]] && mount -v /home
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ conf_locale()
|
||||
|
||||
# Removing locales not in the list
|
||||
prnt I "Deactivating initial locales from installation..."
|
||||
if [[ $(grep -v '^#' $gen_fname | grep -v -e '^[[:space:]]*$') ]]; then
|
||||
if [[ -n $(grep -v '^#' $gen_fname | grep -v -e '^[[:space:]]*$') ]]; then
|
||||
grep -v '^#' $gen_fname | grep -v -e '^[[:space:]]*$' |
|
||||
while read -r line; do
|
||||
sed -i "s/$line/# $line/" $gen_fname
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
# * MAIL_RELAY: Name of the mail relay server
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
export VER_conf_mail="0.0.7"
|
||||
export VER_conf_mail="0.0.8"
|
||||
export DEP_conf_mail="upgrade_dist"
|
||||
|
||||
conf_mail()
|
||||
@@ -30,7 +30,7 @@ conf_mail()
|
||||
-e "s/@MAIL_RELAY@/$MAIL_RELAY/" $pfmain
|
||||
|
||||
echo $HOSTNAME.$REALM > /etc/mailname
|
||||
tag_file /etc/mailname
|
||||
#tag_file /etc/mailname
|
||||
|
||||
svc_restart postfix
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ conf_network()
|
||||
ifup -a || true && prnt W "Ignoring errors here."
|
||||
|
||||
unset iface if_file
|
||||
NEED_REBOOT=true
|
||||
export NEED_REBOOT=true
|
||||
}
|
||||
|
||||
precheck_conf_network()
|
||||
|
||||
@@ -24,16 +24,16 @@ conf_nfs()
|
||||
pkginst nfs-common
|
||||
for mnt in $NFS_MOUNTS; do
|
||||
local mnt_serv=${!MOUNTSERV_$mnt}
|
||||
local mnt_point=${!MOUNTPOINT_$mnt}
|
||||
local mnt_point="${!MOUNTPOINT_$mnt}"
|
||||
local mnt_opts=${!MOUNTOPTS_$mnt:-"defaults,_netdev"}
|
||||
if [[ ! $(grep "$mnt_serv" /etc/fstab) ]]; then
|
||||
echo -e "${mnt_serv}\t${mnt_point}\tnfs4\tdefaults,_netdev\t0\t0" >> /etc/fstab
|
||||
if [[ -z $(grep "$mnt_serv" /etc/fstab) ]]; then
|
||||
echo -e "${mnt_serv}\t${mnt_point}\tnfs4\t${mnt_opts}\t0\t0" >> /etc/fstab
|
||||
fi
|
||||
unset mnt_serv
|
||||
if [[ ! -d $mnt_point ]]; then
|
||||
mkdir -pv $mnt_point
|
||||
mkdir -pv "$mnt_point"
|
||||
fi
|
||||
mount $mnt_point
|
||||
mount "$mnt_point"
|
||||
unset mnt_point
|
||||
done
|
||||
}
|
||||
|
||||
@@ -38,15 +38,15 @@ conf_ntp()
|
||||
|
||||
prnt I "Installing NTP configuration file..."
|
||||
local dest="${conf_file}.work"
|
||||
backup_dist $conf_file
|
||||
install_file ntp.conf $dest
|
||||
tag_file $dest
|
||||
backup_dist "$conf_file"
|
||||
install_file ntp.conf "$dest"
|
||||
tag_file "$dest"
|
||||
local line=""
|
||||
for srv in $NTP_SERVERS; do
|
||||
line="${line}server $srv iburst\n"
|
||||
done
|
||||
sed -i -e "s/@SERVERLIST@/$line/" $dest &&
|
||||
mv -fv $dest $conf_file
|
||||
sed -i -e "s/@SERVERLIST@/$line/" "$dest" &&
|
||||
mv -fv "$dest" "$conf_file"
|
||||
|
||||
prnt I "Starting service ntp..."
|
||||
|
||||
|
||||
@@ -32,13 +32,17 @@ install_chromium()
|
||||
prnt I "Adding Debian Bullseye repository to software sources..."
|
||||
install_file debian_bullseye.list /etc/apt/sources.list.d/
|
||||
;;
|
||||
22.04|22.10|23.04|23.10)
|
||||
prnt I "Adding Debian Bookworm repository to software sources..."
|
||||
install_file debian_bookworm.list /etc/apt/sources.list.d/
|
||||
;;
|
||||
esac
|
||||
|
||||
# Install Debian GPG keys
|
||||
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys DCC9EFBF77E11517
|
||||
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 648ACFD622F3D138
|
||||
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys AA8E81B4331F7F50
|
||||
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 112695A0E562B32A
|
||||
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys "DCC9EFBF77E11517"
|
||||
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys "648ACFD622F3D138"
|
||||
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys "AA8E81B4331F7F50"
|
||||
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys "112695A0E562B32A"
|
||||
|
||||
# Install package manager conf file for Chromium
|
||||
install_file apt_chromium.conf /etc/apt/preferences.d/
|
||||
@@ -69,6 +73,9 @@ precheck_install_chromium()
|
||||
20.04|20.10|21.04|21.10)
|
||||
prnt m " * Detected Ubuntu $SYS_VER, will install Bullseye version of Chromium"
|
||||
;;
|
||||
22.04|22.10|23.04|23.10)
|
||||
prnt m " * Detected Ubuntu $SYS_VER, will install Bookworm version of Chromium"
|
||||
;;
|
||||
*)
|
||||
prnt E "Unable to determine the corresponding Debian version."
|
||||
die 165
|
||||
|
||||
@@ -24,12 +24,12 @@ install_desktop()
|
||||
prnt I "Installing additionnal X11 drivers..."
|
||||
pkginst $X11_DRV
|
||||
fi
|
||||
if [[ $UBUNTU_FLAVOR ]]; then
|
||||
if [[ -n $UBUNTU_FLAVOR ]]; then
|
||||
prnt I "Installing $UBUNTU_FLAVOR environment..."
|
||||
pkginst ${UBUNTU_FLAVOR}-desktop
|
||||
fi
|
||||
# Because we're lazy but manual actions can avoid reboot...
|
||||
NEED_REBOOT=true
|
||||
export NEED_REBOOT=true
|
||||
}
|
||||
|
||||
precheck_install_desktop()
|
||||
|
||||
@@ -25,7 +25,7 @@ install_pkg()
|
||||
fi
|
||||
|
||||
# Blacklist some anoying packages (and remove them if needed)
|
||||
if [[ -n PKGS_BLACKLIST ]]; then
|
||||
if [[ -n $PKGS_BLACKLIST ]]; then
|
||||
for pkg in $PKGS_BLACKLIST; do
|
||||
prnt I "Placing $pkg into the blacklist..."
|
||||
local dest=/etc/apt/preferences.d/blacklist_$pkg
|
||||
@@ -51,13 +51,13 @@ install_pkg()
|
||||
|
||||
precheck_install_pkg()
|
||||
{
|
||||
if [[ -z PKGS_RMLIST ]]; then
|
||||
if [[ -z $PKGS_RMLIST ]]; then
|
||||
prnt m " * No package to remove."
|
||||
else
|
||||
prnt m " * $(echo $PKGS_RMLIST | wc -w) package to remove."
|
||||
fi
|
||||
|
||||
if [[ -z PKGS_BLACKLIST ]]; then
|
||||
if [[ -z $PKGS_BLACKLIST ]]; then
|
||||
prnt m " * The packages $pkg will be placed into the blacklist !"
|
||||
file_must_exists pkgman/blacklist.conf
|
||||
else
|
||||
|
||||
@@ -30,7 +30,7 @@ install_profile()
|
||||
#tag_file $usr/.tmux.conf{,.local}
|
||||
if [[ ! -d $usr/profile ]]; then
|
||||
(
|
||||
cd $usr
|
||||
cd $usr || return 205
|
||||
git config --global http.sslverify false
|
||||
git clone https://git.geoffray-levasseur.org/fatalerrors/profile.git
|
||||
git config --global http.sslverify true
|
||||
|
||||
@@ -20,7 +20,7 @@ select_system_proxy()
|
||||
else
|
||||
prnt I "No proxy configuration set, nothing to do."
|
||||
fi
|
||||
NEED_REBOOT=true
|
||||
export NEED_REBOOT=true
|
||||
}
|
||||
|
||||
precheck_select_system_proxy()
|
||||
|
||||
@@ -29,10 +29,12 @@ upgrade_dist()
|
||||
# We backup entire apt dir
|
||||
backup_dist /etc/apt
|
||||
prnt I "Basic apt configuration..."
|
||||
tag_file $norecommend
|
||||
echo 'APT::Install-Recommends "false";' >> $norecommends
|
||||
echo 'APT::AutoRemove::RecommendsImportant "false";' >> $norecommends
|
||||
echo 'APT::AutoRemove::SuggestsImportant "false";' >> $norecommends
|
||||
tag_file $norecommends
|
||||
{
|
||||
echo 'APT::Install-Recommends "false";'
|
||||
echo 'APT::AutoRemove::RecommendsImportant "false";'
|
||||
echo 'APT::AutoRemove::SuggestsImportant "false";'
|
||||
} >> $norecommends
|
||||
|
||||
prnt I "Configuring proxy for APT..."
|
||||
if [[ -n $PROXY_APT ]]; then
|
||||
|
||||
Reference in New Issue
Block a user