Ask Your Question
0

Trouble making init.d script on Fedora 26

asked 2017-09-16 13:58:10 -0600

Sol33t303 gravatar image

I have been trying to get my script to run on boot but it won't, I have made the file executable. What am I doing wrong? Here is the code.

#!/bin/bash
# Shadowsocksserver Shadows socks server
# chkconfig: 2345 99 01
# description: This script autostarts my Shadow Socks server
# processname: 1834
. /etc/init.d/functions
start() {
     sudo ssserver -c /etc/shadowsocks.json -d start

}

stop() {
    sudo ssserver -c /etc/shadowsocks.json -d stop
}

case "$1" in
start)
stop)
status)
restart)
*)
esac

This is my first time trying to make a init.d script. The script is meant to start my shadow socks proxy.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2017-09-16 19:07:18 -0600

aeperezt gravatar image

Fedora 26 use systemd, systemd use different way to load services than init.d, you should follow systemd standard this should be a good reading to lear and do Read This

Using systemd you script should be something like this:

[Unit]
Description=service_description
After=network.target

[Service]
ExecStart=ssserver -c /etc/shadowsocks.json
ExecStop=ssserver -c /etc/shadowsocks.json -d stop

[Install]
WantedBy=default.target

That is to give you and idea of how simple is creating a service on systemd, you may need to add the path to access ssserver and if it need to run as specific user add that in the script. Hope this help good luck.

edit flag offensive delete link more

Comments

Thanks for the help, here is the new code

[Unit]
Description=Autostarts my Shadowsocks proxy server
After=network.target

[Service]
ExecStart=/usr/bin/ssserver -c /etc/shadowsocks.json
ExecStop=ssserver -c /etc/shadowsocks.json -d stop

[Install]
WantedBy=default.target

I have also made it executable, however, it doesn't look like it's working. Here is the output of systemctl status Shadowsocksserver.service: https://pastebin.com/JNWEBJUY I had to use a link because I reached the character limit.

Sol33t303 gravatar imageSol33t303 ( 2017-09-17 01:50:22 -0600 )edit

Guess you need to select a different socket port, a port not already being used

socket.error: [Errno 98] Address already in use
villykruse gravatar imagevillykruse ( 2017-09-17 08:07:40 -0600 )edit

I've edited it again and here is the new code and output:

[Unit]
Description=Autostarts my Shadowsocks proxy server
After=network.target

[Service]
ExecStart="/home/Sol33t303/bin/Shadowsocks server"
ExecStop="/home/Sol33t303/bin/Shadowsocks server stop"

[Install]
WantedBy=default.target

It looked like doing this resulted in less errors https://pastebin.com/ZUw0HDjm It looks like I'm running into permission problems right now, which doesn't make sense because I'm using root.

Sol33t303 gravatar imageSol33t303 ( 2017-09-17 15:48:24 -0600 )edit

Look like you need to set some SeLinux rules to make it work as service, try using it with selinux as permissive.

aeperezt gravatar imageaeperezt ( 2017-09-17 21:36:06 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2017-09-16 13:58:10 -0600

Seen: 393 times

Last updated: Sep 16 '17