adding first patch for the unit file

Signed-off-by: Uncle Stinky <uncle.stinky@ghostchain.io>
This commit is contained in:
Uncle Stinky 2025-04-29 21:45:01 +03:00
parent bdc094663d
commit eab90d4173
Signed by: st1nky
GPG Key ID: 016064BD97603B40
2 changed files with 34 additions and 0 deletions

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/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