Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED]autossh init script reporting failure but succeeding
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
eponymous
Tux's lil' helper
Tux's lil' helper


Joined: 02 Feb 2005
Posts: 141

PostPosted: Tue Feb 21, 2012 1:11 pm    Post subject: [SOLVED]autossh init script reporting failure but succeeding Reply with quote

Hi,

I have the following script which runs at startup:

Code:
     depend() {
             need net
             after dns
     }
     
     AUTOSSH_PIDFILE=/var/run/autossh/autossh-tunnel.pid
     AUTOSSH_BINARY=/usr/bin/autossh
     AUTOSSH_MONITOR_PORT=20000
     USER=scponly
     HOST=scponly@myhost.com
     # For reverse access
     FORWARD_OPT1="-R 2222:localhost:22"
     # CCTV camera
     FORWARD_OPT2="-L 5540:10.0.0.1:554"
     # CCTV camera
     FORWARD_OPT3="-L 5541:10.0.0.2:554"
     # HTTP proxy
     FORWARD_OPT4="-D 1080"
     
     start() {
             export AUTOSSH_PIDFILE
             ebegin "Setting up SSH tunnel(s)."
             start-stop-daemon --start --user "${USER}" \
             --name autossh-tunnel \
             --pidfile "${AUTOSSH_PIDFILE}" \
             --exec "${AUTOSSH_BINARY}" -u "${USER}" -- -M "${AUTOSSH_MONITOR_PORT}" -f "${FORWARD_OPT1}" "${FORWARD_OPT2}" "${FORWARD_OPT3}" "${FORWARD_OPT4}" -N "${HOST}"
             eend $?
     }
     
     stop() {
             ebegin "Closing SSH tunnel(s)."
             start-stop-daemon --stop --user "${USER}" \
             --name autossh-tunnel \
             --exec "${AUTOSSH_BINARY}" \
             --pidfile "${AUTOSSH_PIDFILE}"
             eend $?
     }


If I run the script manually *after* startup, everything works fine with no errors reported. The scponly user has access to /var/run/autossh to make the pid file.

However as soon as I do an:
Code:

rc-update add autossh-script default


... and reboot I get this message in rc.log (same message is in /var/log/messages):

Code:
      * Setting up SSH tunnel(s). ...
      * start-stop-daemon: did not create a valid pid in `/var/run/autossh/autossh-tunnel.pid'
     [ !! ]
     * ERROR: autossh-tunnel-tuxfs-v2 failed to start


But it does create the file with the correct PID and autossh works fine and I can use the tunnel!

What is going on here?


Last edited by eponymous on Wed Feb 22, 2012 8:49 am; edited 1 time in total
Back to top
View user's profile Send private message
eponymous
Tux's lil' helper
Tux's lil' helper


Joined: 02 Feb 2005
Posts: 141

PostPosted: Tue Feb 21, 2012 3:58 pm    Post subject: Reply with quote

If it helps I have the following configuration for scponly in my /etc/passwd:

Code:
scponly:x:105:101:added by portage for scponly:/home/scponly//:/usr/sbin/scponlyc


and it doesn't allow me to have a login shell which could cause issues perhaps?
Back to top
View user's profile Send private message
eponymous
Tux's lil' helper
Tux's lil' helper


Joined: 02 Feb 2005
Posts: 141

PostPosted: Wed Feb 22, 2012 8:48 am    Post subject: Reply with quote

Ok solved. The permissions on the /var/run/autossh directory were at fault. I re-created the directory as root and did a "chown -R scponly:scponly autossh" and it has set the permissions fine.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
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
You cannot vote in polls in this forum