Replace double white spaces with tabulations.
This commit is contained in:
parent
bea48dcbd0
commit
c74afb440b
|
@ -2,11 +2,11 @@
|
|||
|
||||
# Script pour ajouter une machine à sauvegarder dans BackupPC
|
||||
# Modifie les fichiers:
|
||||
# /etc/hosts
|
||||
# /etc/backuppc/hosts
|
||||
# /etc/backuppc/NOM_UTILISATEUR.NOM_MACHINE.pl
|
||||
# /var/lib/backuppc/.ssh/config
|
||||
# /var/lib/backuppc/.ssh/known_hosts
|
||||
# /etc/hosts
|
||||
# /etc/backuppc/hosts
|
||||
# /etc/backuppc/NOM_UTILISATEUR.NOM_MACHINE.pl
|
||||
# /var/lib/backuppc/.ssh/config
|
||||
# /var/lib/backuppc/.ssh/known_hosts
|
||||
|
||||
#### HOW TO ####
|
||||
# scp file.pl backuppc.ipr.univ-rennes1.fr:
|
||||
|
@ -17,7 +17,7 @@
|
|||
#### DÉPENDANCES ####
|
||||
# ldapsearch (pkg ldap-utils)
|
||||
if [ ! $(command -v ldapsearch) ]; then
|
||||
aptitude install dos2unix ldap-utils
|
||||
aptitude install dos2unix ldap-utils
|
||||
fi
|
||||
|
||||
# Liste des fichiers
|
||||
|
@ -33,14 +33,14 @@ config_pl_name=$(basename -- "${config_pl_path}")
|
|||
|
||||
#### VÉRIFIER QUE L’ON A BIEN LES DROITS ADMIN ####
|
||||
if [ "$EUID" -ne 0 ]; then
|
||||
printf '\e[1;31m%-6s\e[m' "À lancer avec les droits administrateur"
|
||||
exit
|
||||
printf '\e[1;31m%-6s\e[m' "À lancer avec les droits administrateur"
|
||||
exit
|
||||
fi
|
||||
|
||||
#### VÉRIFIER QUE LE FICHIER EXISTE BIEN ####
|
||||
if [ ! -f "${config_pl_path}" ]; then
|
||||
printf '\e[1;31m%-6s\e[m' "Installation annulée, le fichier n'existe pas !"
|
||||
exit
|
||||
printf '\e[1;31m%-6s\e[m' "Installation annulée, le fichier n'existe pas !"
|
||||
exit
|
||||
fi
|
||||
|
||||
#### VÉRIFIER QUE LE FICHIER EST BIEN EN UTF-8 ####
|
||||
|
@ -69,24 +69,24 @@ backup_username=$(grep "# username:" ${config_pl_path} | cut -d':' -f 2)
|
|||
#### TESTS ####
|
||||
# Check IP
|
||||
if [[ ${ip_ur1} != "129.20" ]]; then
|
||||
printf "La machine cliente n'était pas sur le réseau UR1\n"
|
||||
exit 1
|
||||
printf "La machine cliente n'était pas sur le réseau UR1\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check mail
|
||||
if [[ ${mail_ur1} != "univ-rennes1.fr" ]]; then
|
||||
printf "Le client n'a pas renseigné une adresse UR1\n"
|
||||
exit 1
|
||||
printf "Le client n'a pas renseigné une adresse UR1\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#### AJOUTER L HÔTE DANS ${BACKUPPC_CONFIG_DIR}/HOSTS ####
|
||||
# jfade.pr079076.spm.univ-rennes1.fr 0 jfade
|
||||
if [[ ! $(grep "${username}.${hostname}" "${backuppc_host_file}") ]]; then
|
||||
echo "${username}.${hostname} 0 ${username}" >> "${backuppc_host_file}"
|
||||
#echo "WRITE TO ${backuppc_host_file}: ${username}.${hostname} 0 ${username}"
|
||||
echo "${username}.${hostname} 0 ${username}" >> "${backuppc_host_file}"
|
||||
#echo "WRITE TO ${backuppc_host_file}: ${username}.${hostname} 0 ${username}"
|
||||
else
|
||||
printf '\e[1;31m%-6s\e[m' "Installation annulée, la ligne ${username}.${hostname} existe déjà dans ${backuppc_host_file} !"
|
||||
exit
|
||||
printf '\e[1;31m%-6s\e[m' "Installation annulée, la ligne ${username}.${hostname} existe déjà dans ${backuppc_host_file} !"
|
||||
exit
|
||||
fi
|
||||
|
||||
#### AJOUTER LA CLEF SSH DE LA MACHINE DE L'UTILISATEUR ####
|
||||
|
@ -97,27 +97,27 @@ else
|
|||
hostkey=$(grep "# hostkey:" ${config_pl_path} | cut -d':' -f 2)
|
||||
fi
|
||||
if [[ ! $(grep "${fqdn}" "${backuppc_known_host_file}") ]]; then
|
||||
echo "${fqdn} ${hostkey}" >> "${backuppc_known_host_file}"
|
||||
#echo "WRITE TO ${backuppc_known_host_file}: ${fqdn} ${hostkey}"
|
||||
echo "${fqdn} ${hostkey}" >> "${backuppc_known_host_file}"
|
||||
#echo "WRITE TO ${backuppc_known_host_file}: ${fqdn} ${hostkey}"
|
||||
else
|
||||
printf '\e[1;31m%-6s\e[m' "Installation annulée, la clef ssh pour ${username}.${fqdn} existe déjà dans ${backuppc_known_host_file} !"
|
||||
#exit
|
||||
#### NO EXIT !!! #### NEED ${fqdn} and NOT ${username}.${fqdn}
|
||||
printf '\e[1;31m%-6s\e[m' "Installation annulée, la clef ssh pour ${username}.${fqdn} existe déjà dans ${backuppc_known_host_file} !"
|
||||
#exit
|
||||
#### NO EXIT !!! #### NEED ${fqdn} and NOT ${username}.${fqdn}
|
||||
fi
|
||||
|
||||
#### DÉFINIR L'HÔTE DANS LA CONFIGURATION SSH ####
|
||||
# Host jfade.pr079076
|
||||
# hostname pr079076.spm.univ-rennes1.fr
|
||||
# hostname pr079076.spm.univ-rennes1.fr
|
||||
if [[ ! $(grep "${username}.${hostname}" "${backuppc_ssh_config_file}") ]]; then
|
||||
cat << EOF >> "${backuppc_ssh_config_file}"
|
||||
Host ${username}.${hostname}
|
||||
hostname ${fqdn}
|
||||
hostname ${fqdn}
|
||||
EOF
|
||||
|
||||
# Pour une machine Windows DSI, backup_user particulier
|
||||
if [[ ${backup_username} ]]; then
|
||||
cat << EOF >> "${backuppc_ssh_config_file}"
|
||||
user "${backup_username}"
|
||||
user "${backup_username}"
|
||||
|
||||
EOF
|
||||
else
|
||||
|
@ -130,20 +130,20 @@ fi
|
|||
|
||||
#### DÉFINIR LE NOM D'HOTE POUR LE SYSTEME ####
|
||||
if [[ ! $(grep "${ip}" "${system_hosts}") ]]; then
|
||||
echo "${ip} ${username}.${hostname}" >> "${system_hosts}"
|
||||
#echo "WRITE TO ${system_hosts}: ${ip} ${username}.${hostname}"
|
||||
echo "${ip} ${username}.${hostname}" >> "${system_hosts}"
|
||||
#echo "WRITE TO ${system_hosts}: ${ip} ${username}.${hostname}"
|
||||
else
|
||||
printf '\e[1;31m%-6s\e[m' "Le nom d'hôte ${username}.${hostname} est déjà connu du système (${system_hosts})!"
|
||||
printf '\e[1;31m%-6s\e[m' "Le nom d'hôte ${username}.${hostname} est déjà connu du système (${system_hosts})!"
|
||||
fi
|
||||
|
||||
#### DÉPLACER LE FICHIER DANS LE RÉPERTOIRE DE BACKUPPC ####
|
||||
if [ ! -f "${backuppc_config_dir}/${username}.hostname" ]; then
|
||||
mv "${config_pl_path}" "${backuppc_config_dir}/${username}.${hostname}.pl"
|
||||
chown backuppc:www-data "${backuppc_config_dir}/${username}.${hostname}.pl"
|
||||
#printf "TODO||TOREMOVE: mv ${config_pl_path}" "${backuppc_config_dir}/${username}.${hostname}.pl"
|
||||
mv "${config_pl_path}" "${backuppc_config_dir}/${username}.${hostname}.pl"
|
||||
chown backuppc:www-data "${backuppc_config_dir}/${username}.${hostname}.pl"
|
||||
#printf "TODO||TOREMOVE: mv ${config_pl_path}" "${backuppc_config_dir}/${username}.${hostname}.pl"
|
||||
else
|
||||
printf '\e[1;31m%-6s\e[m' "Installation annulée, le fichier ${username}.${hostname}.pl existe déjà dans ${backuppc_config_dir}/ !"
|
||||
exit
|
||||
printf '\e[1;31m%-6s\e[m' "Installation annulée, le fichier ${username}.${hostname}.pl existe déjà dans ${backuppc_config_dir}/ !"
|
||||
exit
|
||||
fi
|
||||
|
||||
#### recharger la configuration de backuppc ####
|
||||
|
|
Loading…
Reference in New Issue