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"
|
export NTP_SERVERS="didicas.$REALM cagua.$REALM"
|
||||||
|
|
||||||
# Ceph share
|
# Ceph share
|
||||||
export CEPH_SRV_NAMES="mayon pinatubo ragang taal jolo"
|
export CEPH_SRV_NAMES="mayon pinatubo ragang taal"
|
||||||
export CEPHIP_mayon="192.168.1.254"
|
export CEPHIP_mayon="192.168.1.254"
|
||||||
export CEPHIP_pinatubo="192.168.1.253"
|
export CEPHIP_pinatubo="192.168.1.253"
|
||||||
export CEPHIP_ragang="192.168.1.252"
|
export CEPHIP_ragang="192.168.1.252"
|
||||||
export CEPHIP_taal="192.168.1.251"
|
export CEPHIP_taal="192.168.1.251"
|
||||||
export CEPHIP_jolo="192.168.1.30"
|
#export CEPHIP_jolo="192.168.1.30"
|
||||||
export CEPH_SECRET="AQAxSf5c2A/CMxAAnOu1RrSf7Yr2h60CLttq4g=="
|
export CEPH_SECRET="AQAxSf5c2A/CMxAAnOu1RrSf7Yr2h60CLttq4g=="
|
||||||
export SHARED_HOME="false"
|
export SHARED_HOME="false"
|
||||||
|
|
||||||
|
|||||||
50
init.sh
50
init.sh
@@ -36,10 +36,10 @@ export LC_ALL=C
|
|||||||
export LANG=C
|
export LANG=C
|
||||||
|
|
||||||
# Version of init
|
# 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)
|
# 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
|
# Get hostname
|
||||||
export HOSTNAME=$(hostname)
|
export HOSTNAME=$(hostname)
|
||||||
@@ -65,7 +65,7 @@ function_exists prnt || (
|
|||||||
# ==== Main Program ====
|
# ==== 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)
|
set_sys_vars $(uname -m) $(get_os_version)
|
||||||
|
|
||||||
# Initializing global variables
|
# Initializing global variables
|
||||||
@@ -84,22 +84,22 @@ check_root
|
|||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Logfile variable treatment -- cannot be a function
|
# Logfile variable treatment -- cannot be a function
|
||||||
|
|
||||||
if [[ -n $NEW_LOGFILE ]]; then
|
if [[ -n "$NEW_LOGFILE" ]]; then
|
||||||
export LOGFILE=$NEW_LOGFILE
|
export LOGFILE="$NEW_LOGFILE"
|
||||||
else
|
else
|
||||||
export LOGFILE=${LOGFILE:-"$MYPATH/log/init-$(uname -n)-$(stdtime).log"}
|
export LOGFILE=${LOGFILE:-"$MYPATH/log/init-$(uname -n)-$(stdtime).log"}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
prnt I "Creating log files welcoming directory..."
|
prnt I "Creating log files welcoming directory..."
|
||||||
if [[ ! -d $(dirname $LOGFILE) ]]; then
|
if [[ ! -d $(dirname "$LOGFILE") ]]; then
|
||||||
mkdir -pv $(dirname $LOGFILE)
|
mkdir -pv $(dirname "$LOGFILE")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Log all outputs to the logfile
|
# Log all outputs to the logfile
|
||||||
exec 3>&1 4>&2
|
exec 3>&1 4>&2
|
||||||
trap 'exec 2>&4 1>&3' 0 1 2 3
|
trap 'exec 2>&4 1>&3' 0 1 2 3
|
||||||
exec > >(tee -a $LOGFILE)
|
exec > >(tee -a "$LOGFILE")
|
||||||
exec 2> >(tee -a $LOGFILE >&2)
|
exec 2> >(tee -a "$LOGFILE" >&2)
|
||||||
prnt I "Starting init.sh version $VERSION."
|
prnt I "Starting init.sh version $VERSION."
|
||||||
prnt I "The log file is $LOGFILE."
|
prnt I "The log file is $LOGFILE."
|
||||||
if [[ -n $SYS_CODE ]]; then
|
if [[ -n $SYS_CODE ]]; then
|
||||||
@@ -113,7 +113,7 @@ fi
|
|||||||
|
|
||||||
separator
|
separator
|
||||||
|
|
||||||
if [[ -n $CHROOT_PATH && -z $CHROOT_DONE ]]; then
|
if [[ -n "$CHROOT_PATH" && -z $CHROOT_DONE ]]; then
|
||||||
chroot_bootstrap $@
|
chroot_bootstrap $@
|
||||||
prnt I "Normal end of chrooted execution!"
|
prnt I "Normal end of chrooted execution!"
|
||||||
exit 0
|
exit 0
|
||||||
@@ -139,7 +139,7 @@ separator
|
|||||||
|
|
||||||
if [[ $RUN_SHELL == true ]]; then
|
if [[ $RUN_SHELL == true ]]; then
|
||||||
prnt I "Launching an interactive shell..."
|
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."
|
prnt I "Script execution terminated after interactive shell execution."
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
@@ -165,8 +165,8 @@ if ! command -v wget &> /dev/null; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Run prechecks
|
# Run prechecks
|
||||||
if [[ JUMP != true ]]; then
|
if [[ $JUMP != true ]]; then
|
||||||
tmpfile=$(mktemp /tmp/init-XXXXXX)
|
tmpfile="$(mktemp /tmp/init-XXXXXX)"
|
||||||
if [[ -n $MANUAL_MODULE_LIST ]]; then
|
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
|
fi
|
||||||
@@ -174,11 +174,11 @@ if [[ JUMP != true ]]; then
|
|||||||
prnt W "Dependency checks have been deactivated manually."
|
prnt W "Dependency checks have been deactivated manually."
|
||||||
fi
|
fi
|
||||||
if [[ $RESUME == true ]]; then
|
if [[ $RESUME == true ]]; then
|
||||||
cat $STAGE_FILE >> $tmpfile
|
cat "$STAGE_FILE" >> $tmpfile
|
||||||
fi
|
fi
|
||||||
for mod in $MODULE_LIST; do
|
for mod in $MODULE_LIST; do
|
||||||
version=VER_$mod
|
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}."
|
prnt I "Checks previously executed for $mod version ${!version}."
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
@@ -186,7 +186,7 @@ if [[ JUMP != true ]]; then
|
|||||||
if [[ -z $MANUAL_MODULE_LIST && $NO_DEPS != true ]]; then
|
if [[ -z $MANUAL_MODULE_LIST && $NO_DEPS != true ]]; then
|
||||||
deps=DEP_$mod
|
deps=DEP_$mod
|
||||||
for dep in ${!deps}; do
|
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 "Module $mod have unsatisfied dependencies or is executed too early."
|
||||||
prnt E " * $dep must be executed before $mod, please check your module list."
|
prnt E " * $dep must be executed before $mod, please check your module list."
|
||||||
die 9
|
die 9
|
||||||
@@ -198,9 +198,9 @@ if [[ JUMP != true ]]; then
|
|||||||
(
|
(
|
||||||
precheck_$mod
|
precheck_$mod
|
||||||
)
|
)
|
||||||
echo $mod >> $tmpfile
|
echo $mod >> "$tmpfile"
|
||||||
done
|
done
|
||||||
rm -f $tmpfile
|
rm -f "$tmpfile"
|
||||||
unset mod
|
unset mod
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -234,12 +234,12 @@ echo && separator && echo
|
|||||||
if [[ $key == "C" || $key == 'c' ]]; then
|
if [[ $key == "C" || $key == 'c' ]]; then
|
||||||
# Reinit stage file if no resuming
|
# Reinit stage file if no resuming
|
||||||
if [[ $RESUME != true ]] && [[ -f $STAGE_FILE ]]; then
|
if [[ $RESUME != true ]] && [[ -f $STAGE_FILE ]]; then
|
||||||
rm -f $STAGE_FILE
|
rm -f "$STAGE_FILE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# We launch modules one after one
|
# We launch modules one after one
|
||||||
for mod in $MODULE_LIST; do
|
for mod in $MODULE_LIST; do
|
||||||
if [[ $RESUME == true ]] && [[ $(grep $mod $STAGE_FILE) ]]; then
|
if [[ $RESUME == true ]] && [[ $(grep $mod "$STAGE_FILE") ]]; then
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
# We need this only if JUMP is set but doesn't matter if it's done again
|
# 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
|
export REBOOT_NEEDED=false
|
||||||
$mod
|
$mod
|
||||||
if [[ $REBOOT_NEEDED == true ]]; then
|
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
|
else
|
||||||
echo $mod >> $STAGE_FILE # Mark as done for resuming function
|
echo "$mod" >> "$STAGE_FILE" # Mark as done for resuming function
|
||||||
fi
|
fi
|
||||||
)
|
)
|
||||||
separator
|
separator
|
||||||
@@ -265,15 +265,15 @@ fi
|
|||||||
prnt I "That's all folks !"
|
prnt I "That's all folks !"
|
||||||
echo
|
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 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 's/ reboot//' | \
|
||||||
sed ':a' -e 'N' -e '$!ba' -e 's/\n/ /g')"
|
sed ':a' -e 'N' -e '$!ba' -e 's/\n/ /g')"
|
||||||
prnt I "Please reboot now or as soon as possible!"
|
prnt I "Please reboot now or as soon as possible!"
|
||||||
echo
|
echo
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rm -f $STAGEFILE
|
rm -f "$STAGE_FILE"
|
||||||
exit 0
|
exit 0
|
||||||
# EOF
|
# EOF
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Error management functions
|
# Error management functions
|
||||||
# This file is part of the init.sh project
|
# This file is part of the init.sh project
|
||||||
@@ -29,7 +30,7 @@ function die()
|
|||||||
unset errorcode
|
unset errorcode
|
||||||
|
|
||||||
# Put the trigger back (only executed with --keepgoing)
|
# Put the trigger back (only executed with --keepgoing)
|
||||||
trap "error ${LINENO}" ERR
|
trap 'error ${LINENO}' ERR
|
||||||
}
|
}
|
||||||
export -f die
|
export -f die
|
||||||
|
|
||||||
@@ -73,8 +74,8 @@ trap "error ${LINENO}; backtrace; err_exit" ERR
|
|||||||
function err_exit
|
function err_exit
|
||||||
{
|
{
|
||||||
if [[ $KEEPGOING != true ]]; then
|
if [[ $KEEPGOING != true ]]; then
|
||||||
if [[ -f $tmpfile ]]; then
|
if [[ -f "$tmpfile" ]]; then
|
||||||
rm -f $tmpfile
|
rm -f "$tmpfile"
|
||||||
fi
|
fi
|
||||||
exit 255
|
exit 255
|
||||||
fi
|
fi
|
||||||
@@ -94,7 +95,7 @@ function backtrace
|
|||||||
printf '%15s() %s:%d\n' \
|
printf '%15s() %s:%d\n' \
|
||||||
"$func" "${BASH_SOURCE[$i]}" "${BASH_LINENO[ (( $i - 1)) ]}"
|
"$func" "${BASH_SOURCE[$i]}" "${BASH_LINENO[ (( $i - 1)) ]}"
|
||||||
fi
|
fi
|
||||||
let i++ || true
|
(( i++ )) || true
|
||||||
done
|
done
|
||||||
unset func i
|
unset func i
|
||||||
echo "=============================="
|
echo "=============================="
|
||||||
@@ -120,7 +121,7 @@ noerror()
|
|||||||
fi
|
fi
|
||||||
echo $?
|
echo $?
|
||||||
|
|
||||||
trap "error ${LINENO}" ERR
|
trap 'error ${LINENO}' ERR
|
||||||
set -o errexit
|
set -o errexit
|
||||||
}
|
}
|
||||||
export -f noerror
|
export -f noerror
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Chroot system functions
|
# Chroot system functions
|
||||||
# This file is part of the init.sh project
|
# This file is part of the init.sh project
|
||||||
@@ -13,36 +14,36 @@
|
|||||||
# If chrooted, we need to bootstrap to a new copy of our directory tree
|
# If chrooted, we need to bootstrap to a new copy of our directory tree
|
||||||
chroot_bootstrap()
|
chroot_bootstrap()
|
||||||
{
|
{
|
||||||
if [[ ! -d $CHROOT_PATH ]]; then
|
if [[ ! -d "$CHROOT_PATH" ]]; then
|
||||||
prnt E "The path given to chroot don't exists."
|
prnt E "The path given to chroot don't exists."
|
||||||
die 14
|
die 14
|
||||||
fi
|
fi
|
||||||
if [[ ! -d $CHROOT_PATH/tmp ]]; then
|
if [[ ! -d "$CHROOT_PATH/tmp" ]]; then
|
||||||
prnt E "The target filesystem doesn't seems to be a valid installation."
|
prnt E "The target filesystem doesn't seems to be a valid installation."
|
||||||
die 15
|
die 15
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local tmpdir=$(mktemp -d $CHROOT_PATH/tmp/init.sh-XXXX)
|
local tmpdir=$(mktemp -d "$CHROOT_PATH/tmp/init.sh-XXXX")
|
||||||
local bootstrap_items="conf lib modules repo bash.rc init.sh prepost.d"
|
local bootstrap_items="conf lib modules repo bash.rc init.sh prepost.d"
|
||||||
if [[ $RESUME == true ]]; then
|
if [[ $RESUME == true ]]; then
|
||||||
bootstrap_items="$bootstrap_items $STAGE_FILE"
|
bootstrap_items="$bootstrap_items $STAGE_FILE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
prnt I "Preparing root change."
|
prnt I "Preparing root change."
|
||||||
cp -av $bootstrap_items $tmpdir
|
cp -av $bootstrap_items "$tmpdir"
|
||||||
|
|
||||||
prnt I "Changing root and starting a fork of init.sh..."
|
prnt I "Changing root and starting a fork of init.sh..."
|
||||||
# on the following line, true allows to correctly exit in case of error since
|
# on the following line, true allows to correctly exit in case of error since
|
||||||
# errors are managed by the chrooted environment
|
# errors are managed by the chrooted environment
|
||||||
chroot $CHROOT_PATH /bin/bash -c 'CHROOT_DONE=true; $tmpdir/init.sh $@' || true
|
chroot "$CHROOT_PATH" /bin/bash -c 'CHROOT_DONE=true; "$tmpdir/init.sh" "$@"' || true
|
||||||
|
|
||||||
# If stage file still exists we copy it to be able to resume later
|
# If stage file still exists we copy it to be able to resume later
|
||||||
if [[ -e $tmpdir/$(basename $STAGE_FILE) ]]; then
|
if [[ -e "$tmpdir/$(basename "$STAGE_FILE")" ]]; then
|
||||||
cp $tmpdir/$(basename $STAGE_FILE) $STAGE_FILE
|
cp "$tmpdir/$(basename "$STAGE_FILE")" "$STAGE_FILE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
prnt I "Back to host system and clean up."
|
prnt I "Back to host system and clean up."
|
||||||
rm -rf $tmpdir
|
rm -rf "$tmpdir"
|
||||||
}
|
}
|
||||||
|
|
||||||
# EOF
|
# EOF
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#!/bin/env bash
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Main program functions
|
# Main program functions
|
||||||
# This file is part of the init.sh project
|
# This file is part of the init.sh project
|
||||||
@@ -14,39 +15,46 @@
|
|||||||
# errors with immediate exit.
|
# errors with immediate exit.
|
||||||
read_commandline()
|
read_commandline()
|
||||||
{
|
{
|
||||||
syntax_error()
|
|
||||||
{
|
|
||||||
prnt E "Error while analysing command line parameters."
|
|
||||||
die 1 --force
|
|
||||||
}
|
|
||||||
|
|
||||||
# Processing command line options
|
# Processing command line options
|
||||||
local want_module=false
|
|
||||||
local want_logfile=false
|
|
||||||
local want_conffile=false
|
|
||||||
local want_chroot=false
|
|
||||||
local opt=
|
local opt=
|
||||||
for opt in $@; do
|
local params=''
|
||||||
case $opt in
|
params=$(getopt -n init.sh -o hvm:cjkrRDoPl:f:s \
|
||||||
|
--long help,version,module:,check-only,jump,keep-going,resume,no-root-check,no-deps,offline,no-proxy,logfile:,file:,shell,chroot,cron \
|
||||||
|
-- "$@")
|
||||||
|
eval set -- "$params"
|
||||||
|
while true; do
|
||||||
|
case $1 in
|
||||||
"-h"|"--help")
|
"-h"|"--help")
|
||||||
disp_help
|
disp_help
|
||||||
|
shift
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
"-v"|"--version")
|
"-v"|"--version")
|
||||||
show_version
|
show_version
|
||||||
|
shift
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
"-m"|"--module")
|
"-m"|"--module")
|
||||||
local want_module=true
|
if [[ -z $MANUAL_MODULE_LIST ]]; then
|
||||||
|
export MANUAL_MODULE_LIST=$2
|
||||||
|
else
|
||||||
|
prnt E "A module list have already been given!"
|
||||||
|
prnt E "Commande line only tolerate one --module parameter."
|
||||||
|
die 1 --force
|
||||||
|
fi
|
||||||
|
shift 2
|
||||||
;;
|
;;
|
||||||
"-c"|"--check-only")
|
"-c"|"--check-only")
|
||||||
export CHECK_ONLY=true
|
export CHECK_ONLY=true
|
||||||
|
shift
|
||||||
;;
|
;;
|
||||||
"-j"|"--jump")
|
"-j"|"--jump")
|
||||||
export JUMP=true
|
export JUMP=true
|
||||||
|
shift
|
||||||
;;
|
;;
|
||||||
"-k"|"--keep-going")
|
"-k"|"--keep-going")
|
||||||
export KEEPGOING=true
|
export KEEPGOING=true
|
||||||
|
shift
|
||||||
;;
|
;;
|
||||||
"-r"|"--resume")
|
"-r"|"--resume")
|
||||||
if [[ -s $STAGE_FILE ]]; then
|
if [[ -s $STAGE_FILE ]]; then
|
||||||
@@ -56,91 +64,68 @@ read_commandline()
|
|||||||
prnt E "Without it, resuming is impossible."
|
prnt E "Without it, resuming is impossible."
|
||||||
die 17 --force
|
die 17 --force
|
||||||
fi
|
fi
|
||||||
|
shift
|
||||||
;;
|
;;
|
||||||
"-R"|"--no-root-check")
|
"-R"|"--no-root-check")
|
||||||
export NO_ROOT_CHECK=true
|
export NO_ROOT_CHECK=true
|
||||||
|
shift
|
||||||
;;
|
;;
|
||||||
"-D"|"--no-deps")
|
"-D"|"--no-deps")
|
||||||
export NO_DEPS=true
|
export NO_DEPS=true
|
||||||
|
shift
|
||||||
;;
|
;;
|
||||||
"-o"|"--offline")
|
"-o"|"--offline")
|
||||||
export OFFLINE=true
|
export OFFLINE=true
|
||||||
|
shift
|
||||||
;;
|
;;
|
||||||
"-P"|"--no-proxy")
|
"-P"|"--no-proxy")
|
||||||
export NO_PROXY=true
|
export NO_PROXY=true
|
||||||
|
shift
|
||||||
;;
|
;;
|
||||||
"-l"|"--logfile")
|
"-l"|"--logfile")
|
||||||
local want_logfile=true
|
|
||||||
;;
|
|
||||||
"-f"|"--file")
|
|
||||||
local want_conffile=true
|
|
||||||
;;
|
|
||||||
"-s"|"--shell")
|
|
||||||
export RUN_SHELL=true
|
|
||||||
;;
|
|
||||||
"--chroot")
|
|
||||||
local want_chroot=true
|
|
||||||
;;
|
|
||||||
"--cron")
|
|
||||||
export CRON_MODE=true
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
if [[ $want_module == true ]]; then
|
|
||||||
[[ $want_logfile == true ]] && synthax_error
|
|
||||||
[[ $want_conffile == true ]] && synthax_error
|
|
||||||
[[ $want_chroot == true ]] && synthax_error
|
|
||||||
if [[ -z $MANUAL_MODULE_LIST ]]; then
|
|
||||||
export MANUAL_MODULE_LIST=$opt
|
|
||||||
want_module=false
|
|
||||||
else
|
|
||||||
prnt E "A module list have already been given!"
|
|
||||||
prnt E "Commande line only tolerate one --module parameter."
|
|
||||||
die 1 --force
|
|
||||||
fi
|
|
||||||
elif [[ $want_logfile == true ]]; then
|
|
||||||
[[ $want_module == true ]] && synthax_error
|
|
||||||
[[ $want_conffile == true ]] && synthax_error
|
|
||||||
[[ $want_chroot == true ]] && synthax_error
|
|
||||||
if [[ -z $NEW_LOGFILE ]]; then
|
if [[ -z $NEW_LOGFILE ]]; then
|
||||||
export NEW_LOGFILE=$opt
|
export NEW_LOGFILE=$2
|
||||||
want_logfile=false
|
|
||||||
else
|
else
|
||||||
prnt E "Impossible to specify several log files."
|
prnt E "Impossible to specify several log files."
|
||||||
die 1 --force
|
die 1 --force
|
||||||
fi
|
fi
|
||||||
elif [[ $want_conffile == true ]]; then
|
shift 2
|
||||||
[[ $want_module == true ]] && synthax_error
|
;;
|
||||||
[[ $want_logfile == true ]] && synthax_error
|
"-f"|"--file")
|
||||||
[[ $want_chroot == true ]] && synthax_error
|
|
||||||
export CONFFILES="$CONFFILES $opt"
|
export CONFFILES="$CONFFILES $opt"
|
||||||
want_logfile=false
|
shift 2
|
||||||
elif [[ $want_chroot == true ]]; then
|
;;
|
||||||
[[ $want_module == true ]] && synthax_error
|
"-s"|"--shell")
|
||||||
[[ $want_logfile == true ]] && synthax_error
|
export RUN_SHELL=true
|
||||||
[[ $want_conffile == true ]] && synthax_error
|
shift
|
||||||
|
;;
|
||||||
|
"--chroot")
|
||||||
if [[ -z $CHROOT_PATH ]]; then
|
if [[ -z $CHROOT_PATH ]]; then
|
||||||
export CHROOT_PATH=$opt
|
export CHROOT_PATH=$2
|
||||||
want_chroot=false
|
|
||||||
else
|
else
|
||||||
prnt E "A chroot path have already been given."
|
prnt E "A chroot path have already been given."
|
||||||
die 1 --force
|
die 1 --force
|
||||||
fi
|
fi
|
||||||
else
|
shift 2
|
||||||
prnt E "Unknow parameter \"$opt\"."
|
;;
|
||||||
die 1 --force
|
"--cron")
|
||||||
|
export CRON_MODE=true
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
--)
|
||||||
|
shift
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
if [[ -n $1 ]]; then
|
||||||
|
prnt E "Unknow parameter \"$1\" !"
|
||||||
|
die 1
|
||||||
fi
|
fi
|
||||||
|
break
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
unset opt
|
unset opt
|
||||||
|
|
||||||
# If those var are true at that point, something is wrong
|
|
||||||
if [[ $want_logfile == true ]] || [[ $want_module == true ]] ||
|
|
||||||
[[ $want_conffile == true ]] || [[ $want_chroot == true ]]; then
|
|
||||||
syntax_error
|
|
||||||
fi
|
|
||||||
|
|
||||||
unset want_conffile want_logfile want_module want_chroot
|
|
||||||
}
|
}
|
||||||
export -f read_commandline
|
export -f read_commandline
|
||||||
|
|
||||||
@@ -180,11 +165,12 @@ process_commandline_and_vars()
|
|||||||
|
|
||||||
# Configure module list
|
# Configure module list
|
||||||
if [[ -n $MANUAL_MODULE_LIST ]]; then
|
if [[ -n $MANUAL_MODULE_LIST ]]; then
|
||||||
prnt W "A manual module list will be used."
|
prnt W "A manual module list will be used:"
|
||||||
export MODULE_LIST=$(echo $MANUAL_MODULE_LIST | sed "s/,/ /g")
|
export MODULE_LIST=${MANUAL_MODULE_LIST//,/ /g}
|
||||||
|
prnt m " * $MODULE_LIST"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check for module list existance and basic syntax
|
# Check for module list exis<tance and basic syntax
|
||||||
if [[ -n $MODULE_LIST ]]; then
|
if [[ -n $MODULE_LIST ]]; then
|
||||||
for mod in $MODULE_LIST; do
|
for mod in $MODULE_LIST; do
|
||||||
if [[ $mod =~ ['-!@#$%\&*=+'] ]]; then
|
if [[ $mod =~ ['-!@#$%\&*=+'] ]]; then
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Disks and partitions manipulation function
|
# Disks and partitions manipulation function
|
||||||
# This file is part of the init.sh project
|
# This file is part of the init.sh project
|
||||||
@@ -82,7 +83,7 @@ mkparts()
|
|||||||
local tmpfile=$(mktemp sfd.XXXX)
|
local tmpfile=$(mktemp sfd.XXXX)
|
||||||
if [[ -n $1 ]]; then
|
if [[ -n $1 ]]; then
|
||||||
# For each given size we make a partition
|
# For each given size we make a partition
|
||||||
for $part in $@; do
|
for part in $@; do
|
||||||
# If size is zero we interpret it as all available space
|
# If size is zero we interpret it as all available space
|
||||||
if [[ $part == 0 ]]; then
|
if [[ $part == 0 ]]; then
|
||||||
echo ",,L" >> $tmpfile
|
echo ",,L" >> $tmpfile
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Some display functions and defines color codes
|
# Some display functions and defines color codes
|
||||||
# This file is part of the init.sh project
|
# This file is part of the init.sh project
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# File manipulation function
|
# File manipulation function
|
||||||
# This file is part of the init.sh project
|
# This file is part of the init.sh project
|
||||||
@@ -34,7 +35,7 @@ backup_dist()
|
|||||||
if [[ -L ${file} ]]; then
|
if [[ -L ${file} ]]; then
|
||||||
# With symbolik links we call again backup_dist to treat target
|
# With symbolik links we call again backup_dist to treat target
|
||||||
prnt I "Following the symbolic link $file to do a proper backup..."
|
prnt I "Following the symbolic link $file to do a proper backup..."
|
||||||
backup_dist $(readlink -f ${file})
|
backup_dist $(readlink -f "${file}")
|
||||||
elif [[ -f ${file} ]]; then
|
elif [[ -f ${file} ]]; then
|
||||||
prnt I "Creating a backup of ${file} on $tmstmp..."
|
prnt I "Creating a backup of ${file} on $tmstmp..."
|
||||||
cp -av $file ${file}.dist.${tmstmp}
|
cp -av $file ${file}.dist.${tmstmp}
|
||||||
@@ -134,7 +135,7 @@ install_file()
|
|||||||
prnt E "install_file(): At least two arguments are required."
|
prnt E "install_file(): At least two arguments are required."
|
||||||
die 11
|
die 11
|
||||||
fi
|
fi
|
||||||
if [[ $(echo $@ | grep "\*\|\?") ]]; then
|
if [[ -n $(echo $@ | grep "\*\|\?") ]]; then
|
||||||
prnt E "install_file(): Wildcards are not authorized."
|
prnt E "install_file(): Wildcards are not authorized."
|
||||||
die 7
|
die 7
|
||||||
fi
|
fi
|
||||||
@@ -215,7 +216,7 @@ is_dir_empty()
|
|||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
nbfiles=$(ls -a1 $dir | egrep -v '^.$|^..$' | wc -l)
|
nbfiles=$(ls -a1 $dir | grep -Evc '^.$|^..$')
|
||||||
if [[ $nbfiles -eq 0 ]]; then
|
if [[ $nbfiles -eq 0 ]]; then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
@@ -240,7 +241,7 @@ patch_file()
|
|||||||
|
|
||||||
# Create a sub-process, to avoid bash environment pollution
|
# Create a sub-process, to avoid bash environment pollution
|
||||||
(
|
(
|
||||||
local varlist= pattern=
|
local varlist='' pattern=''
|
||||||
if [[ $# -eq 0 ]] ; then
|
if [[ $# -eq 0 ]] ; then
|
||||||
pattern="-e s/<\(.*\)>/\$\1\$\1/g"
|
pattern="-e s/<\(.*\)>/\$\1\$\1/g"
|
||||||
else
|
else
|
||||||
@@ -249,7 +250,6 @@ patch_file()
|
|||||||
if ! declare -p $var >/dev/null 2>&1 ; then
|
if ! declare -p $var >/dev/null 2>&1 ; then
|
||||||
local $var=$(eval echo \$$var)
|
local $var=$(eval echo \$$var)
|
||||||
fi
|
fi
|
||||||
export $var
|
|
||||||
pattern="$pattern -e s/@$var@/\$$var/g"
|
pattern="$pattern -e s/@$var@/\$$var/g"
|
||||||
varlist=$varlist\$$var
|
varlist=$varlist\$$var
|
||||||
done
|
done
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Loaders for conf and prepost functions
|
# Loaders for conf and prepost functions
|
||||||
# This file is part of the init.sh project
|
# This file is part of the init.sh project
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Network functions
|
# Network functions
|
||||||
# This file is part of the init.sh project
|
# This file is part of the init.sh project
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Package manager integration
|
# Package manager integration
|
||||||
# This file is part of the init.sh project
|
# This file is part of the init.sh project
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Services manipulation functions
|
# Services manipulation functions
|
||||||
# This file is part of the init.sh project
|
# This file is part of the init.sh project
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Base support function
|
# Base support function
|
||||||
# This file is part of the init.sh project
|
# This file is part of the init.sh project
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Various utilitary functions
|
# Various utilitary functions
|
||||||
# This file is part of the init.sh project
|
# This file is part of the init.sh project
|
||||||
@@ -25,7 +26,7 @@ function_exists() {
|
|||||||
die 11 --force
|
die 11 --force
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $(LC_ALL=C type -t $1 | grep function) ]]; then
|
if [[ -n $(LC_ALL=C type -t $1 | grep function) ]]; then
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
return 1
|
return 1
|
||||||
@@ -42,7 +43,7 @@ get_mod_name()
|
|||||||
prnt E "get_mod_name(): Bad number of parameters."
|
prnt E "get_mod_name(): Bad number of parameters."
|
||||||
die 11 --force
|
die 11 --force
|
||||||
fi
|
fi
|
||||||
echo $(basename $1 | cut -f 1 -d '.')
|
basename $1 | cut -f 1 -d '.'
|
||||||
}
|
}
|
||||||
export -f get_mod_name
|
export -f get_mod_name
|
||||||
|
|
||||||
@@ -52,7 +53,7 @@ export -f get_mod_name
|
|||||||
trim()
|
trim()
|
||||||
{
|
{
|
||||||
local string="$@"
|
local string="$@"
|
||||||
echo "$(sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//'<<<"${string}")"
|
sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//'<<<"${string}"
|
||||||
unset string
|
unset string
|
||||||
}
|
}
|
||||||
export -f trim
|
export -f trim
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Version determination function
|
# Version determination function
|
||||||
# This file is part of the init.sh project
|
# This file is part of the init.sh project
|
||||||
@@ -37,7 +38,7 @@ get_os_version()
|
|||||||
unset maj min
|
unset maj min
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Return values on stdout
|
# Return values on stdout (awk used to retreave primary codename when using testing or unstable)
|
||||||
echo ${ID,,} ${VERSION_ID} $(echo ${VERSION_CODENAME,,} | awk '{print $1}')
|
echo ${ID,,} ${VERSION_ID} $(echo ${VERSION_CODENAME,,} | awk '{print $1}')
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -20,22 +20,22 @@
|
|||||||
# * DEFAULT_SHELL: The shell to use when creating new users
|
# * DEFAULT_SHELL: The shell to use when creating new users
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
export VER_authnz=0.2.2
|
export VER_authnz="0.2.2"
|
||||||
export DEP_authnz="upgrade_dist"
|
export DEP_authnz="upgrade_dist"
|
||||||
|
|
||||||
# Users (from Ldap)
|
# Users (from Ldap)
|
||||||
add_remote_user()
|
add_remote_user()
|
||||||
{
|
{
|
||||||
if [[ $(grep "^$1:" /etc/passwd) ]]; then
|
if [[ -n $(grep "^$1:" /etc/passwd) ]]; then
|
||||||
prnt W "A local user with name $1 already exists, adding anyway!"
|
prnt W "A local user with name $1 already exists, adding anyway!"
|
||||||
fi
|
fi
|
||||||
if [[ $(grep "^+$1:" /etc/passwd) ]]; then
|
if [[ -n $(grep "^+$1:" /etc/passwd) ]]; then
|
||||||
prnt W "The remote user $1 is already declared, nothing to do in passwd."
|
prnt W "The remote user $1 is already declared, nothing to do in passwd."
|
||||||
else
|
else
|
||||||
echo "+$1::::::" >> /etc/passwd
|
echo "+$1::::::" >> /etc/passwd
|
||||||
prnt I "User $1 added to passwd..."
|
prnt I "User $1 added to passwd..."
|
||||||
fi
|
fi
|
||||||
if [[ $(grep "^+$1:" /etc/shadow) ]]; then
|
if [[ -n $(grep "^+$1:" /etc/shadow) ]]; then
|
||||||
prnt W "The remote user $1 is already connectable, nothing to do in shadow."
|
prnt W "The remote user $1 is already connectable, nothing to do in shadow."
|
||||||
else
|
else
|
||||||
echo "+$1::::::::" >> /etc/shadow
|
echo "+$1::::::::" >> /etc/shadow
|
||||||
@@ -46,10 +46,10 @@ add_remote_user()
|
|||||||
# Remove users
|
# Remove users
|
||||||
remove_user()
|
remove_user()
|
||||||
{
|
{
|
||||||
if [[ $(grep "^$1:" /etc/{passwd,shadow,group,gshadow}) ]]; then
|
if [[ -n $(grep "^$1:" /etc/{passwd,shadow,group,gshadow}) ]]; then
|
||||||
# Using sed is more universal than any distro commands - local case
|
# Using sed is more universal than any distro commands - local case
|
||||||
sed -i -e "/^$1:/d" /etc/{passwd,shadow,group,gshadow}
|
sed -i -e "/^$1:/d" /etc/{passwd,shadow,group,gshadow}
|
||||||
elif [[ $(grep "^+$1:" /etc/{passwd,shadow,group,gshadow}) ]]; then
|
elif [[ -n $(grep "^+$1:" /etc/{passwd,shadow,group,gshadow}) ]]; then
|
||||||
# remote case
|
# remote case
|
||||||
sed -i -e "/^+$1:/d" /etc/{passwd,shadow,group,gshadow}
|
sed -i -e "/^+$1:/d" /etc/{passwd,shadow,group,gshadow}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ conf_ceph()
|
|||||||
pkginst ceph-common
|
pkginst ceph-common
|
||||||
|
|
||||||
# hosts files required for Ceph bootstrap when DNS not yet started
|
# hosts files required for Ceph bootstrap when DNS not yet started
|
||||||
if [[ ! $(grep "# Ceph" /etc/hosts) ]]; then
|
if [[ -z $(grep "# Ceph" /etc/hosts) ]]; then
|
||||||
prnt I "Adding server list to /etc/hosts"
|
prnt I "Adding server list to /etc/hosts"
|
||||||
backup_dist /etc/hosts
|
backup_dist /etc/hosts
|
||||||
tag_file /etc/hosts
|
tag_file /etc/hosts
|
||||||
@@ -57,7 +57,7 @@ conf_ceph()
|
|||||||
fstabchanged=true
|
fstabchanged=true
|
||||||
echo >> /etc/fstab
|
echo >> /etc/fstab
|
||||||
local srvlist=$(echo $CEPH_SRV_NAMES | sed "s/ /,/g")
|
local srvlist=$(echo $CEPH_SRV_NAMES | sed "s/ /,/g")
|
||||||
if [[ ! $(grep $srvlist /etc/fstab) ]]; then
|
if [[ -z $(grep $srvlist /etc/fstab) ]]; then
|
||||||
echo "# Ceph :" >> /etc/fstab
|
echo "# Ceph :" >> /etc/fstab
|
||||||
echo "$srvlist:/ /srv/ceph ceph defaults,_netdev,name=admin,secret=$CEPH_SECRET 0 0" >> /etc/fstab
|
echo "$srvlist:/ /srv/ceph ceph defaults,_netdev,name=admin,secret=$CEPH_SECRET 0 0" >> /etc/fstab
|
||||||
else
|
else
|
||||||
@@ -72,7 +72,7 @@ conf_ceph()
|
|||||||
prnt I "Adding Samba entries to /etc/fstab"
|
prnt I "Adding Samba entries to /etc/fstab"
|
||||||
fstabchanged=true
|
fstabchanged=true
|
||||||
echo >> /etc/fstab
|
echo >> /etc/fstab
|
||||||
if [[ ! $(grep $SMBSRV /etc/fstab) ]]; then
|
if [[ -z $(grep $SMBSRV /etc/fstab) ]]; then
|
||||||
echo "# Samba:" >> /etc/fstab
|
echo "# Samba:" >> /etc/fstab
|
||||||
echo "//$SMBSRV/share /srv/ceph/share cifs defaults,_netdev,username=root,password= 0 0" >> /etc/fstab
|
echo "//$SMBSRV/share /srv/ceph/share cifs defaults,_netdev,username=root,password= 0 0" >> /etc/fstab
|
||||||
else
|
else
|
||||||
@@ -83,7 +83,7 @@ conf_ceph()
|
|||||||
prnt E "Ceph status not understood, the next tasks will probably fail"
|
prnt E "Ceph status not understood, the next tasks will probably fail"
|
||||||
fi
|
fi
|
||||||
if [[ $success == yes ]]; then
|
if [[ $success == yes ]]; then
|
||||||
if [[ ! $(grep "^/srv/ceph/share" /etc/fstab) ]]; then
|
if [[ -z $(grep "^/srv/ceph/share" /etc/fstab) ]]; then
|
||||||
fstabchanged=true
|
fstabchanged=true
|
||||||
echo "/srv/ceph/share /share none defaults,_netdev,bind 0 0" >> /etc/fstab
|
echo "/srv/ceph/share /share none defaults,_netdev,bind 0 0" >> /etc/fstab
|
||||||
if [[ $SHARED_HOME == 1 ]]; then
|
if [[ $SHARED_HOME == 1 ]]; then
|
||||||
@@ -101,10 +101,10 @@ conf_ceph()
|
|||||||
|
|
||||||
# Mount Ceph volumes if required
|
# Mount Ceph volumes if required
|
||||||
prnt I "Mounting ceph volumes"
|
prnt I "Mounting ceph volumes"
|
||||||
[[ ! $(mount | grep "on /srv/ceph") ]] && mount -v /srv/ceph || mount -v /srv/ceph/share
|
[[ -z $(mount | grep "on /srv/ceph") ]] && mount -v /srv/ceph || mount -v /srv/ceph/share
|
||||||
[[ ! $(mount | grep "on /share") ]] && mount -v /share
|
[[ -z $(mount | grep "on /share") ]] && mount -v /share
|
||||||
if [[ $SHARED_HOME == "true" ]]; then
|
if [[ $SHARED_HOME == "true" ]]; then
|
||||||
[[ ! $(mount | grep "on /home") ]] && mount -v /home
|
[[ -z $(mount | grep "on /home") ]] && mount -v /home
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ precheck_conf_disks()
|
|||||||
prnt I "Le dique $drv est vierge, il sera formaté en $CALCTYPE."
|
prnt I "Le dique $drv est vierge, il sera formaté en $CALCTYPE."
|
||||||
else
|
else
|
||||||
prnt W "Le disque $drv n'est pas vierge !"
|
prnt W "Le disque $drv n'est pas vierge !"
|
||||||
if [[ $FORCEBLANK==true ]]; then
|
if [[ $FORCEBLANK == true ]]; then
|
||||||
prnt W "Le disque $drv sera réinitialisé !"
|
prnt W "Le disque $drv sera réinitialisé !"
|
||||||
else
|
else
|
||||||
prnt E "La réinitialisation de $drv n'est pas autorisé, rien ne sera fait !"
|
prnt E "La réinitialisation de $drv n'est pas autorisé, rien ne sera fait !"
|
||||||
@@ -119,7 +119,7 @@ precheck_conf_disks()
|
|||||||
(( drvcount+=1 ))
|
(( drvcount+=1 ))
|
||||||
done
|
done
|
||||||
|
|
||||||
if [[ ! $CALCTYPE=="zfs" && drvcount -gt 1 ]]; then
|
if [[ ! $CALCTYPE == "zfs" && drvcount -gt 1 ]]; then
|
||||||
prnt E "Plusieurs diques impossibles avec Ext4 ou XFS !"
|
prnt E "Plusieurs diques impossibles avec Ext4 ou XFS !"
|
||||||
die 150
|
die 150
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ conf_locale()
|
|||||||
|
|
||||||
# Removing locales not in the list
|
# Removing locales not in the list
|
||||||
prnt I "Deactivating initial locales from installation..."
|
prnt I "Deactivating initial locales from installation..."
|
||||||
if [[ $(grep -v '^#' $gen_fname | grep -v -e '^[[:space:]]*$') ]]; then
|
if [[ -n $(grep -v '^#' $gen_fname | grep -v -e '^[[:space:]]*$') ]]; then
|
||||||
grep -v '^#' $gen_fname | grep -v -e '^[[:space:]]*$' |
|
grep -v '^#' $gen_fname | grep -v -e '^[[:space:]]*$' |
|
||||||
while read -r line; do
|
while read -r line; do
|
||||||
sed -i "s/$line/# $line/" $gen_fname
|
sed -i "s/$line/# $line/" $gen_fname
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
# * MAIL_RELAY: Name of the mail relay server
|
# * MAIL_RELAY: Name of the mail relay server
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
export VER_conf_mail="0.0.7"
|
export VER_conf_mail="0.0.8"
|
||||||
export DEP_conf_mail="upgrade_dist"
|
export DEP_conf_mail="upgrade_dist"
|
||||||
|
|
||||||
conf_mail()
|
conf_mail()
|
||||||
@@ -30,7 +30,7 @@ conf_mail()
|
|||||||
-e "s/@MAIL_RELAY@/$MAIL_RELAY/" $pfmain
|
-e "s/@MAIL_RELAY@/$MAIL_RELAY/" $pfmain
|
||||||
|
|
||||||
echo $HOSTNAME.$REALM > /etc/mailname
|
echo $HOSTNAME.$REALM > /etc/mailname
|
||||||
tag_file /etc/mailname
|
#tag_file /etc/mailname
|
||||||
|
|
||||||
svc_restart postfix
|
svc_restart postfix
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ conf_network()
|
|||||||
ifup -a || true && prnt W "Ignoring errors here."
|
ifup -a || true && prnt W "Ignoring errors here."
|
||||||
|
|
||||||
unset iface if_file
|
unset iface if_file
|
||||||
NEED_REBOOT=true
|
export NEED_REBOOT=true
|
||||||
}
|
}
|
||||||
|
|
||||||
precheck_conf_network()
|
precheck_conf_network()
|
||||||
|
|||||||
@@ -24,16 +24,16 @@ conf_nfs()
|
|||||||
pkginst nfs-common
|
pkginst nfs-common
|
||||||
for mnt in $NFS_MOUNTS; do
|
for mnt in $NFS_MOUNTS; do
|
||||||
local mnt_serv=${!MOUNTSERV_$mnt}
|
local mnt_serv=${!MOUNTSERV_$mnt}
|
||||||
local mnt_point=${!MOUNTPOINT_$mnt}
|
local mnt_point="${!MOUNTPOINT_$mnt}"
|
||||||
local mnt_opts=${!MOUNTOPTS_$mnt:-"defaults,_netdev"}
|
local mnt_opts=${!MOUNTOPTS_$mnt:-"defaults,_netdev"}
|
||||||
if [[ ! $(grep "$mnt_serv" /etc/fstab) ]]; then
|
if [[ -z $(grep "$mnt_serv" /etc/fstab) ]]; then
|
||||||
echo -e "${mnt_serv}\t${mnt_point}\tnfs4\tdefaults,_netdev\t0\t0" >> /etc/fstab
|
echo -e "${mnt_serv}\t${mnt_point}\tnfs4\t${mnt_opts}\t0\t0" >> /etc/fstab
|
||||||
fi
|
fi
|
||||||
unset mnt_serv
|
unset mnt_serv
|
||||||
if [[ ! -d $mnt_point ]]; then
|
if [[ ! -d $mnt_point ]]; then
|
||||||
mkdir -pv $mnt_point
|
mkdir -pv "$mnt_point"
|
||||||
fi
|
fi
|
||||||
mount $mnt_point
|
mount "$mnt_point"
|
||||||
unset mnt_point
|
unset mnt_point
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,15 +38,15 @@ conf_ntp()
|
|||||||
|
|
||||||
prnt I "Installing NTP configuration file..."
|
prnt I "Installing NTP configuration file..."
|
||||||
local dest="${conf_file}.work"
|
local dest="${conf_file}.work"
|
||||||
backup_dist $conf_file
|
backup_dist "$conf_file"
|
||||||
install_file ntp.conf $dest
|
install_file ntp.conf "$dest"
|
||||||
tag_file $dest
|
tag_file "$dest"
|
||||||
local line=""
|
local line=""
|
||||||
for srv in $NTP_SERVERS; do
|
for srv in $NTP_SERVERS; do
|
||||||
line="${line}server $srv iburst\n"
|
line="${line}server $srv iburst\n"
|
||||||
done
|
done
|
||||||
sed -i -e "s/@SERVERLIST@/$line/" $dest &&
|
sed -i -e "s/@SERVERLIST@/$line/" "$dest" &&
|
||||||
mv -fv $dest $conf_file
|
mv -fv "$dest" "$conf_file"
|
||||||
|
|
||||||
prnt I "Starting service ntp..."
|
prnt I "Starting service ntp..."
|
||||||
|
|
||||||
|
|||||||
@@ -32,13 +32,17 @@ install_chromium()
|
|||||||
prnt I "Adding Debian Bullseye repository to software sources..."
|
prnt I "Adding Debian Bullseye repository to software sources..."
|
||||||
install_file debian_bullseye.list /etc/apt/sources.list.d/
|
install_file debian_bullseye.list /etc/apt/sources.list.d/
|
||||||
;;
|
;;
|
||||||
|
22.04|22.10|23.04|23.10)
|
||||||
|
prnt I "Adding Debian Bookworm repository to software sources..."
|
||||||
|
install_file debian_bookworm.list /etc/apt/sources.list.d/
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Install Debian GPG keys
|
# Install Debian GPG keys
|
||||||
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys DCC9EFBF77E11517
|
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys "DCC9EFBF77E11517"
|
||||||
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 648ACFD622F3D138
|
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys "648ACFD622F3D138"
|
||||||
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys AA8E81B4331F7F50
|
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys "AA8E81B4331F7F50"
|
||||||
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 112695A0E562B32A
|
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys "112695A0E562B32A"
|
||||||
|
|
||||||
# Install package manager conf file for Chromium
|
# Install package manager conf file for Chromium
|
||||||
install_file apt_chromium.conf /etc/apt/preferences.d/
|
install_file apt_chromium.conf /etc/apt/preferences.d/
|
||||||
@@ -69,6 +73,9 @@ precheck_install_chromium()
|
|||||||
20.04|20.10|21.04|21.10)
|
20.04|20.10|21.04|21.10)
|
||||||
prnt m " * Detected Ubuntu $SYS_VER, will install Bullseye version of Chromium"
|
prnt m " * Detected Ubuntu $SYS_VER, will install Bullseye version of Chromium"
|
||||||
;;
|
;;
|
||||||
|
22.04|22.10|23.04|23.10)
|
||||||
|
prnt m " * Detected Ubuntu $SYS_VER, will install Bookworm version of Chromium"
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
prnt E "Unable to determine the corresponding Debian version."
|
prnt E "Unable to determine the corresponding Debian version."
|
||||||
die 165
|
die 165
|
||||||
|
|||||||
@@ -24,12 +24,12 @@ install_desktop()
|
|||||||
prnt I "Installing additionnal X11 drivers..."
|
prnt I "Installing additionnal X11 drivers..."
|
||||||
pkginst $X11_DRV
|
pkginst $X11_DRV
|
||||||
fi
|
fi
|
||||||
if [[ $UBUNTU_FLAVOR ]]; then
|
if [[ -n $UBUNTU_FLAVOR ]]; then
|
||||||
prnt I "Installing $UBUNTU_FLAVOR environment..."
|
prnt I "Installing $UBUNTU_FLAVOR environment..."
|
||||||
pkginst ${UBUNTU_FLAVOR}-desktop
|
pkginst ${UBUNTU_FLAVOR}-desktop
|
||||||
fi
|
fi
|
||||||
# Because we're lazy but manual actions can avoid reboot...
|
# Because we're lazy but manual actions can avoid reboot...
|
||||||
NEED_REBOOT=true
|
export NEED_REBOOT=true
|
||||||
}
|
}
|
||||||
|
|
||||||
precheck_install_desktop()
|
precheck_install_desktop()
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ install_pkg()
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Blacklist some anoying packages (and remove them if needed)
|
# Blacklist some anoying packages (and remove them if needed)
|
||||||
if [[ -n PKGS_BLACKLIST ]]; then
|
if [[ -n $PKGS_BLACKLIST ]]; then
|
||||||
for pkg in $PKGS_BLACKLIST; do
|
for pkg in $PKGS_BLACKLIST; do
|
||||||
prnt I "Placing $pkg into the blacklist..."
|
prnt I "Placing $pkg into the blacklist..."
|
||||||
local dest=/etc/apt/preferences.d/blacklist_$pkg
|
local dest=/etc/apt/preferences.d/blacklist_$pkg
|
||||||
@@ -51,13 +51,13 @@ install_pkg()
|
|||||||
|
|
||||||
precheck_install_pkg()
|
precheck_install_pkg()
|
||||||
{
|
{
|
||||||
if [[ -z PKGS_RMLIST ]]; then
|
if [[ -z $PKGS_RMLIST ]]; then
|
||||||
prnt m " * No package to remove."
|
prnt m " * No package to remove."
|
||||||
else
|
else
|
||||||
prnt m " * $(echo $PKGS_RMLIST | wc -w) package to remove."
|
prnt m " * $(echo $PKGS_RMLIST | wc -w) package to remove."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z PKGS_BLACKLIST ]]; then
|
if [[ -z $PKGS_BLACKLIST ]]; then
|
||||||
prnt m " * The packages $pkg will be placed into the blacklist !"
|
prnt m " * The packages $pkg will be placed into the blacklist !"
|
||||||
file_must_exists pkgman/blacklist.conf
|
file_must_exists pkgman/blacklist.conf
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ install_profile()
|
|||||||
#tag_file $usr/.tmux.conf{,.local}
|
#tag_file $usr/.tmux.conf{,.local}
|
||||||
if [[ ! -d $usr/profile ]]; then
|
if [[ ! -d $usr/profile ]]; then
|
||||||
(
|
(
|
||||||
cd $usr
|
cd $usr || return 205
|
||||||
git config --global http.sslverify false
|
git config --global http.sslverify false
|
||||||
git clone https://git.geoffray-levasseur.org/fatalerrors/profile.git
|
git clone https://git.geoffray-levasseur.org/fatalerrors/profile.git
|
||||||
git config --global http.sslverify true
|
git config --global http.sslverify true
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ select_system_proxy()
|
|||||||
else
|
else
|
||||||
prnt I "No proxy configuration set, nothing to do."
|
prnt I "No proxy configuration set, nothing to do."
|
||||||
fi
|
fi
|
||||||
NEED_REBOOT=true
|
export NEED_REBOOT=true
|
||||||
}
|
}
|
||||||
|
|
||||||
precheck_select_system_proxy()
|
precheck_select_system_proxy()
|
||||||
|
|||||||
@@ -29,10 +29,12 @@ upgrade_dist()
|
|||||||
# We backup entire apt dir
|
# We backup entire apt dir
|
||||||
backup_dist /etc/apt
|
backup_dist /etc/apt
|
||||||
prnt I "Basic apt configuration..."
|
prnt I "Basic apt configuration..."
|
||||||
tag_file $norecommend
|
tag_file $norecommends
|
||||||
echo 'APT::Install-Recommends "false";' >> $norecommends
|
{
|
||||||
echo 'APT::AutoRemove::RecommendsImportant "false";' >> $norecommends
|
echo 'APT::Install-Recommends "false";'
|
||||||
echo 'APT::AutoRemove::SuggestsImportant "false";' >> $norecommends
|
echo 'APT::AutoRemove::RecommendsImportant "false";'
|
||||||
|
echo 'APT::AutoRemove::SuggestsImportant "false";'
|
||||||
|
} >> $norecommends
|
||||||
|
|
||||||
prnt I "Configuring proxy for APT..."
|
prnt I "Configuring proxy for APT..."
|
||||||
if [[ -n $PROXY_APT ]]; then
|
if [[ -n $PROXY_APT ]]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user