powerapi/scripts/setup-server.sh

25 lines
639 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-api.service /etc/systemd/system/
if [[ -f '/etc/systemd/system/power-api.service' ]]; then
chmod +x /etc/systemd/system/power-api.service
systemctl daemon-reload
systemctl start power-api.service
systemctl enable power-api.service
systemctl status power-api.service
else
echo 'Service file missing. Something went wrong.'
exit 1
fi