-
Notifications
You must be signed in to change notification settings - Fork 356
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Solution: adding sample template and helper script
- Loading branch information
1 parent
4687b82
commit 6988a00
Showing
3 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# /etc/systemd/system/chain-maind.service | ||
[Unit] | ||
Description=Chain-maind | ||
ConditionPathExists=<CHAIN_MAIND_BINARY> | ||
After=network.target | ||
|
||
[Service] | ||
Type=simple | ||
User=<CHAIN_MAIND_USER> | ||
WorkingDirectory=<CHAIN_MAIND_BINARY_DIR> | ||
ExecStart=<CHAIN_MAIND_BINARY> start --home <CHAIN_MAIND_USER_HOME>/.chain-maind | ||
Restart=on-failure | ||
RestartSec=10 | ||
LimitNOFILE=4096 | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
BASEDIR=$(dirname "$0") | ||
|
||
CHAIN_MAIND_BINARY=$(which chain-maind || (echo -e "\033[31mPlease add chain-maind to PATH\033[0m" 1>&2 && exit 1)) | ||
CHAIN_MAIND_USER=$USER | ||
CHAIN_MAIND_BINARY_DIR=$(dirname $(which chain-maind)) | ||
CHAIN_MAIND_USER_HOME=$(eval echo "~$USER") | ||
|
||
sed "s#<CHAIN_MAIND_BINARY>#$CHAIN_MAIND_BINARY#g; s#<CHAIN_MAIND_USER>#$CHAIN_MAIND_USER#g; s#<CHAIN_MAIND_BINARY_DIR>#$CHAIN_MAIND_BINARY_DIR#g; s#<CHAIN_MAIND_USER_HOME>#$CHAIN_MAIND_USER_HOME#g" $BASEDIR/chain-maind.service.template > $BASEDIR/chain-maind.service | ||
|
||
echo -e "\033[32mGenerated $BASEDIR/chain-maind.service\033[0m" | ||
|
||
if [[ "$OSTYPE" == "linux-gnu"* ]]; then | ||
sudo cp $BASEDIR/chain-maind.service /etc/systemd/system/chain-maind.service | ||
sudo systemctl daemon-reload | ||
sudo systemctl enable chain-maind.service | ||
echo -e "\033[32mCreated /etc/systemd/system/chain-maind.service\033[0m" | ||
else | ||
echo -e "\033[31mCan only create /etc/systemd/system/chain-maind.service for linux\033[0m" 1>&2 | ||
exit 1 | ||
fi |