Create user for backuppc

This commit is contained in:
Jeremy Gardais 2019-05-06 17:13:28 +02:00
parent e5cb0625c7
commit 134c18ff04
Signed by: jegardai
GPG Key ID: E759BAA22501AF32
1 changed files with 23 additions and 1 deletions

View File

@ -15,6 +15,10 @@
## Valeur de fin ## Valeur de fin
SUCCESS=0 SUCCESS=0
ERROR=1 ERROR=1
backuppc_user="backuppc"
backuppc_homedir="/var/lib/backuppc"
## Couleur {{{ ## Couleur {{{
BLACK='\033[49;30m' BLACK='\033[49;30m'
BLACKB='\033[49;90m' BLACKB='\033[49;90m'
@ -31,7 +35,17 @@ RESET='\033[0m'
## }}} ## }}}
# }}} # }}}
# Fonctions {{{ # 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() ## {{{ function ensureSshdIsInstalled() ## {{{
{ {
### `command -v sshd` still return old value even after openssh-server was removed ### `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 ## Mettre à jour le système
aptitude full-upgrade -y --quiet=5 > /dev/null 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 {{{ # Gestion de SSH {{{
ensureSshdIsInstalled ensureSshdIsInstalled