diff --git a/go-daemon/godaemon1.go b/go-daemon/godaemon1.go index 8de9a0d..f4ad256 100644 --- a/go-daemon/godaemon1.go +++ b/go-daemon/godaemon1.go @@ -9,9 +9,9 @@ import ( func main() { cntxt := &daemon.Context{ - PidFileName: "/run/godaemon1.pid", + PidFileName: "/etc/godaemon/godaemon1.pid", PidFilePerm: 0644, - LogFileName: "/var/log/godaemon1.log", + LogFileName: "/etc/godaemon/godaemon1.log", LogFilePerm: 0640, WorkDir: "./", Umask: 027, diff --git a/go-daemon/install.sh b/go-daemon/install.sh index 9e81345..7167ea1 100644 --- a/go-daemon/install.sh +++ b/go-daemon/install.sh @@ -7,18 +7,30 @@ sudo killall godaemon1 sudo systemctl disable godaemon1 sudo systemctl stop godaemon1 sudo systemctl daemon-reload +sudo rm -rf /etc/godaemon1/ # Building temp_dir="$(mktemp -d)" -cd $temp_dir -echo $temp_dir +cd "$temp_dir" || exit +echo "$temp_dir" git clone https://git.aliberksandikci.com.tr/liderahenk/go-daemon -cd go-daemon/go-daemon/ +cd go-daemon/go-daemon/ || exit go build -o ./bin/ +# Configurations +sudo mkdir -p /etc/godaemon1/ +sudo touch /etc/godaemon1/userdata.conf +sudo cat << EOF | sudo tee -a /etc/godaemon1/userdata.conf > /dev/null +The current working directory is: $PWD +You are logged in as $(whoami) +$HOME | $USER | $SUDO_USER +EOF +sudo chown root:root /etc/godaemon1/userdata.conf +sudo chmod 640 /etc/godaemon1/userdata.conf + # Installing sudo mv ./bin/godaemon1 /usr/bin/godaemon1 -if [[ $(ps -jp 1 | awk 'FNR == 2 {print $6}') == "systemd" ]] +if [[ $(ps -jp 1 | awk 'FNR == 2 {print $6} ') == "systemd" ]] then sudo mv ./godaemon1.service /etc/systemd/system/ fi @@ -27,4 +39,4 @@ sudo systemctl enable godaemon1 sudo systemctl start godaemon1 # Post-Cleaning -sudo rm -rf $temp_dir \ No newline at end of file +sudo rm -rf "$temp_dir" \ No newline at end of file