Création du script d'installation
This commit is contained in:
parent
517925a78c
commit
96ae44be39
2 changed files with 52 additions and 1 deletions
51
install.sh
Executable file
51
install.sh
Executable file
|
@ -0,0 +1,51 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Vérifie qu'on est bien en root
|
||||
if [ $(id -u) -ne 0 ]
|
||||
then
|
||||
echo "Ce script doit être executé en root" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# On récupère les options
|
||||
OPTS=$(getopt -o h -l "help,prefix:,database:" -- "$@")
|
||||
eval set -- $OPTS
|
||||
|
||||
set -e
|
||||
|
||||
usage() {
|
||||
echo "Utilisation du script :"
|
||||
echo -e "\t--prefix : où installer suidchecker. Par défaut /usr/local/"
|
||||
echo -e "\t--database : chemin de la base de donnée"
|
||||
echo -e "\t-h, --help : affiche ce message"
|
||||
}
|
||||
|
||||
# Valeurs par défaut
|
||||
_PREFIX="/usr/local"
|
||||
_DB="/usr/local/share/suidchecker/suidchecker.db"
|
||||
|
||||
# On interprète les options
|
||||
while true ; do
|
||||
case "$1" in
|
||||
-h|--help) usage; exit 0;;
|
||||
--prefix) _PREFIX="$2"; shift 2;;
|
||||
--database) _DB="$2"; shift 2;;
|
||||
--) shift; break;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Placement des fichiers
|
||||
mkdir -p $_PREFIX/share/suidchecker $_PREFIX/bin
|
||||
install -g root -o root -m 755 src/*.sh $_PREFIX/share/suidchecker/
|
||||
install -g root -o root -m 755 src/suidchecker $_PREFIX/bin/
|
||||
|
||||
# Création de la configuration
|
||||
echo "DATABASE=$_DB" > /etc/suidchecker.conf
|
||||
echo "INSTALL_PATH=$_PREFIX/share/suidchecker" >> /etc/suidchecker.conf
|
||||
|
||||
# Mise en place de la cron quotidienne
|
||||
echo -e "#/bin/bash\n$_PREFIX/bin/suidchecker --check" > /etc/cron.daily/suidchecker
|
||||
|
||||
# Définition des droits
|
||||
chmod 644 /etc/suidchecker.conf
|
||||
chmod 755 /etc/cron.daily/suidchecker
|
|
@ -7,7 +7,7 @@ then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
. /etc/suidchecker.conf &>/dev/null || . suidchecker.conf &>/dev/null
|
||||
test -f /etc/suidchecker.conf && . /etc/suidchecker.conf || . suidchecker.conf
|
||||
|
||||
export DATABASE
|
||||
export INSTALL_PATH
|
||||
|
|
Loading…
Reference in a new issue