systemd and setup scripts

This commit is contained in:
Kameron Kenny 2024-10-20 20:58:14 -04:00
parent 3064c91f3d
commit d6535affec
No known key found for this signature in database
GPG Key ID: E5006629839D2276
4 changed files with 74 additions and 0 deletions

24
scripts/setup-client.sh Normal file
View File

@ -0,0 +1,24 @@
#!/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

24
scripts/setup-server.sh Normal file
View File

@ -0,0 +1,24 @@
#!/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

View File

@ -0,0 +1,13 @@
[Unit]
Description=Power API Service
After=network.target
[Service]
ExecStart=/usr/bin/python3 /opt/power/api.py
WorkingDirectory=/opt/power/
StandardOutput=journal
StandardError=journal
Restart=always
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1,13 @@
[Unit]
Description=Power Client Service
After=network.target
[Service]
ExecStart=/usr/bin/python3 /opt/power/power_client.py
WorkingDirectory=/opt/power/
StandardOutput=journal
StandardError=journal
Restart=always
[Install]
WantedBy=multi-user.target