Create user for backuppc
This commit is contained in:
parent
e5cb0625c7
commit
134c18ff04
|
@ -15,6 +15,10 @@
|
|||
## Valeur de fin
|
||||
SUCCESS=0
|
||||
ERROR=1
|
||||
|
||||
backuppc_user="backuppc"
|
||||
backuppc_homedir="/var/lib/backuppc"
|
||||
|
||||
## Couleur {{{
|
||||
BLACK='\033[49;30m'
|
||||
BLACKB='\033[49;90m'
|
||||
|
@ -31,7 +35,17 @@ RESET='\033[0m'
|
|||
## }}}
|
||||
# }}}
|
||||
# Fonctions {{{
|
||||
|
||||
function addUserForBackuppc() ## {{{
|
||||
{
|
||||
local userLogin="${1}" ### eg. 'backuppc'
|
||||
local userHomedir="${2}" ### eg. '/var/lib/backuppc'
|
||||
if ! getent passwd "${userLogin}" > /dev/null 2>&1; then
|
||||
printf '%b\n' "${BOLD}L'utilisateur ${userLogin} n'existe pas, tentative de création.${RESET}\\n"
|
||||
useradd --system --shell /bin/sh --home-dir "${userHomedir}/" --create-home -- "${userLogin}"
|
||||
fi
|
||||
chown -R -- "${userLogin}:" "${userHomedir}"
|
||||
}
|
||||
## }}}
|
||||
function ensureSshdIsInstalled() ## {{{
|
||||
{
|
||||
### `command -v sshd` still return old value even after openssh-server was removed
|
||||
|
@ -64,6 +78,14 @@ apt install -y -- aptitude > /dev/null 2>&1
|
|||
|
||||
## Mettre à jour le système
|
||||
aptitude full-upgrade -y --quiet=5 > /dev/null
|
||||
# }}}
|
||||
# Gestion de l'utilisateur pour BackupPC {{{
|
||||
addUserForBackuppc "${backuppc_user}" "${backuppc_homedir}"
|
||||
if [ "$?" != "${SUCCESS}" ]; then
|
||||
printf '%b' "${REDB}La création de l'utilisateur ${backuppc_user} a échouée, installation annulée.${RESET}\\n"
|
||||
exit "${ERROR}"
|
||||
fi
|
||||
|
||||
# }}}
|
||||
# Gestion de SSH {{{
|
||||
ensureSshdIsInstalled
|
||||
|
|
Loading…
Reference in New Issue