#!/usr/bin/env bash CUR_DIR=$(cd `dirname $0`; pwd) SYSTEMD_DIR=/etc/systemd/system ETC_DIR=/etc SERVICE_NAME=map-service SERVICE_FILE_NAME=$SERVICE_NAME.service SCRIPT_FILE_NAME=map-server.sh function service_exists() { local s=$1 if [[ $(systemctl list-units --all -t service --full --no-legend "$s.service" | cut -f1 -d' ') == $s.service ]]; then return 0 fi } if service_exists "$SERVICE_NAME"; then sudo rm $SYSTEMD_DIR/$SERVICE_FILE_NAME sudo rm $ETC_DIR/$SCRIPT_FILE_NAME if systemctl is-active --quiet map-service; then sudo systemctl stop $SERVICE_NAME sudo systemctl disable $SERVICE_NAME sudo systemctl daemon-reload fi else echo "map-service has not been installed" fi