Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Mon Dec 23, 2013 11:13 am 
Offline
Senior Member

Joined: Wed May 13, 2009 1:32 pm
Posts: 737
Location: Italy
Hi,
I need to convert a init.d script to systemctl.

In the start() function of my init.d script I have this code:
Code:
start() {
        echo -n "Starting SSL-SSH-Switch: "
        if [ -f $PIDFILE ]; then
                PID=`cat $PIDFILE`
                echo sslh already running: $PID
                exit 2;
        else
                daemon --user myuser $SSLH $OPTIONS
                RETVAL=$?
                echo
                [ $RETVAL -eq 0 ] && touch $PIDFILE
                [ $RETVAL -eq 0 ] && touch $lockfile
                ip rule add fwmark 0x1 lookup 100;
                ip route add local 0.0.0.0/0 dev lo table 100;
                return $RETVAL
        fi

}


How can I insert this lot of command in a systemctl script?
Can you make an example please?


Top
   
PostPosted: Mon Dec 23, 2013 11:24 am 
Offline

Joined: Sun Sep 13, 2009 11:37 am
Posts: 1
You don't need most of those commands.

Code:
[Unit]
Description=SSL-SSH-Switch

[Service]
# (or Type=forking, if sslh does actually "daemonize" itself)
Type=simple
User=myuser
ExecStart=/usr/bin/sslh --whatever
ExecStartPost=/usr/bin/ip rule add fwmark 0x1 lookup 100
ExecStartPost=/usr/bin/ip route add local 0.0.0.0/0 dev lo table 100
# (probably)
# ExecStopPost=/usr/bin/ip route del local 0.0.0.0/0 dev lo table 100
# ExecStopPost=/usr/bin/ip rule del fwmark 0x1 lookup 100

[Install]
WantedBy=multi-user.target


Related: http://0pointer.de/blog/projects/systemd-for-admins-3.html


Top
   
PostPosted: Mon Dec 23, 2013 11:26 am 
Offline
Senior Member

Joined: Wed May 13, 2009 1:32 pm
Posts: 737
Location: Italy
great, thanks!


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group