52 lines
1.3 KiB
Bash
52 lines
1.3 KiB
Bash
|
#!/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
|