-
-
Save dkackman/517739d1affc9403c2bc8ce4c1125917 to your computer and use it in GitHub Desktop.
chia systemd service unit defintion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# if no parameters are supplied this results in: | |
# . ~/chia-blochain/activate | |
# chia start farmer | |
# | |
if [ -z "$1" ] | |
then | |
operation=start | |
else | |
operation=$1 | |
fi | |
if [ -z "$2" ] | |
then | |
chia_location=~/chia-blockchain | |
else | |
chia_location=$2 | |
fi | |
if [ -z "$3" ] | |
then | |
services=farmer | |
else | |
services=$3 | |
fi | |
if [ ! -d "$chia_location" ] | |
then | |
echo "chia not found: $chia_location" | |
exit 1 | |
fi | |
# enter the venv | |
. $chia_location/activate | |
# start/stop/reload services | |
if [ "$operation" == "start" ] | |
then | |
chia start $services | |
elif [ "$operation" == "stop" ] | |
then | |
chia stop all -d | |
elif [ "$operation" == "reload" ] | |
then | |
chia start $services -r | |
else | |
echo "Unrecognized operation $operation" | |
exit 1 | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=Chia services | |
Requires=network.target | |
After=network.target | |
[Service] | |
Type=forking | |
ExecStart=/usr/local/bin/chia start /home/USERNAME/chia-blockchain farmer | |
ExecStop=/usr/local/bin/chia stop /home/USERNAME/chia-blockchain | |
ExecReload=/usr/local/bin/chia reload /home/USERNAME/chia-blockchain farmer | |
User=USERNAME | |
[Install] | |
WantedBy=multi-user.target |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
On my Raspberry Pi I installed Chia using the ARM deb package, and, In order to autostart services in Raspberry PI, I've to do this:
create the service:
Past the following code:
Then, Must execute the mentioned systemctl commands.