systemd and setup scripts
This commit is contained in:
parent
3064c91f3d
commit
d6535affec
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
Loading…
Reference in New Issue