You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.6 KiB
Bash
56 lines
1.6 KiB
Bash
#!/bin/bash
|
|
|
|
echo "Installing bash monitoring script..."
|
|
|
|
if [ ${UID} -ne 0 ]; then
|
|
echo "Even if the script itself doesn't need to run as root,"
|
|
echo "the installer does need to be started with sudo or as root."
|
|
exit 1
|
|
fi
|
|
|
|
if [ -d /opt/bash-logging ]; then
|
|
echo "It seems like the script is already set up on this system."
|
|
echo "Do you want to overide the old version? Sensors will be kept"
|
|
|
|
while true; do
|
|
read -p "[y/n] " -n 2 CHOICE
|
|
|
|
if [ "${CHOICE}" = "y" ]; then
|
|
SENSORS_TEMP_DIR=$(mktemp -d)
|
|
mv /opt/bash-logging/sensors.d/ /opt/bash-logging/.env ${SENSORS_TEMP_DIR}/
|
|
rm -rf /opt/bash-logging/
|
|
mkdir -p /opt/bash-logging/
|
|
mv ${SENSORS_TEMP_DIR}/sensors.d/ ${SENSORS_TEMP_DIR}/.env /opt/bash-logging/
|
|
|
|
break
|
|
elif [ "${CHOICE}" = "n" ]; then
|
|
exit 1
|
|
fi
|
|
done
|
|
fi
|
|
|
|
echo "Copying files..."
|
|
[ ! -d /opt/bash-logging ] && mkdir /opt/bash-logging
|
|
cp -r inc main.sh /opt/bash-logging/
|
|
|
|
if [ -f /opt/bash-logging/.env ]; then
|
|
echo "Not overwriting existing .env"
|
|
elif [ -f .env ]; then
|
|
echo "Copying local .env"
|
|
cp .env /opt/bash-logging/.env
|
|
else
|
|
echo "Copying template .env, be sure to adjust it!"
|
|
cp .env.example /opt/bash-logging/.env
|
|
fi
|
|
|
|
if [ -d /opt/bash-logging/sensors.d ]; then
|
|
echo "Not overwriting existing sensors.d"
|
|
else
|
|
echo "Copying example sensors.d be sure to adjust it!"
|
|
cp -r sensors.d /opt/bash-logging/
|
|
fi
|
|
|
|
echo "Copying systemd script..."
|
|
cp systemd/bash-logging.service /etc/systemd/system/
|
|
systemctl daemon-reload
|
|
systemctl enable --now bash-logging.service |