powerapi/scripts/setup-client.sh

25 lines
657 B
Bash

#!/usr/bin/env bash
INSTALL_DIR='/opt/power'
[[ ! -d $INSTALL_DIR ]] && mkdir $INSTALL_DIR
if [[ ! -d "${INSTALL_DIR}/.git" ]]; then
git clone https://git.thelinuxpro.net/Utilities/powerapi.git $INSTALL_DIR
else
cd $INSTALL_DIR && git pull
fi
cp ${INSTALL_DIR}/scripts/systemd/power-client.service /etc/systemd/system/
if [[ -f '/etc/systemd/system/power-client.service' ]]; then
chmod +x /etc/systemd/system/power-client.service
systemctl daemon-reload
systemctl start power-client.service
systemctl enable power-client.service
systemctl status power-client.service
else
echo 'Service file missing. Something went wrong.'
exit 1
fi