Compare commits

...

2 Commits

Author SHA1 Message Date
9ce57763cb
extened the template.service for the node and add Requires= rule
Signed-off-by: Uncle Stinky <uncle.stinky@ghostchain.io>
2025-04-29 22:02:33 +03:00
eab90d4173
adding first patch for the unit file
Signed-off-by: Uncle Stinky <uncle.stinky@ghostchain.io>
2025-04-29 21:45:01 +03:00
3 changed files with 36 additions and 1 deletions

View File

@ -1,6 +1,7 @@
[Unit]
Description=Ghost Node
After=network.target
After=network-online.target
Requires=network-online.target
Documentation=https://git.ghostchain.io/ghostchain/ghost-node
[Service]

2
scripts/patch.sh Executable file
View File

@ -0,0 +1,2 @@
SCRIPT_DIR=$(dirname "$0")
bash "$SCRIPT_DIR/patches/patch-1.sh"

32
scripts/patches/patch-1.sh Executable file
View File

@ -0,0 +1,32 @@
DEFAULT_SERVICE_NAME="ghost-node.service"
check_unit_file_validity() {
SERVICE_NAME=$1
if [[ "$SERVICE_NAME" != *.service ]]; then
SERVICE_NAME="${SERVICE_NAME}.service"
fi
SERVICE_FULL_PATH="/etc/systemd/system/$SERVICE_NAME"
if [[ -e "$SERVICE_FULL_PATH" ]]; then
NETWORK_ONLINE_EXISTS=$(grep -Fx "After=network-online.target" "$SERVICE_FULL_PATH")
NETWORK_EXISTS=$(grep -Fx "After=network.target" "$SERVICE_FULL_PATH")
if [[ -z "$NETWORK_ONLINE_EXISTS" && -n "$NETWORK_EXISTS" ]]
then
echo "[-] WARNING: missing network-online.target dependency in $SERVICE_FULL_PATH, trying to replace"
sudo sed -i "s/After=network.target/After=network-online.target\nRequires=network-online.target/g" "$SERVICE_FULL_PATH"
else
echo "[+] INFO: network-online.target is set correctly for $SERVICE_FULL_PATH"
fi
else
echo "[-] No serivce found at $SERVICE_FULL_PATH"
fi
}
check_unit_file_validity $DEFAULT_SERVICE_NAME
read -p "[?] Enter names for the node service, separated by commas (default: ghost-node): " -a SERVICE_NAMES
for NAME in "${SERVICE_NAMES[@]}"; do
check_unit_file_validity $NAME
done
sudo systemctl daemon-reload