Log inUsernamePassword
Log me on automatically each visit    
Register
Register
Log in to check your private messages
Log in to check your private messages
SMS Forum Index » Installation Support

Post new topic   Reply to topic
pid files in /var/run
View previous topic :: View next topic  
Author Message
keopp
Senior Member


Joined: 08 Nov 2008
Posts: 166
Location: Romania

PostPosted: Sun Aug 19, 2012 1:55 pm    Post subject: pid files in /var/run Reply with quote

Hello,

Looking for a server.pid file in /var/run(working to configure an openvpn servr), I strangely found only 3 files(except subdiredtories) inside this directory as follows:

Quote:

2
=acpid.socket
server.pid


The weirdest thing, was the content of the file "2" created today:

Quote:

ls: cannot access 1: No such file or directory
/dev/null
acpid.pid
atd.pid
dhcpd.pid
inetd.pid
klogd.pid
server.pid
sshd.pid
syslogd.pid


And it was right: excepting server.pid recently created, all the other was missing.

Reboot solved the problem but have someone a clue of what is the origin of that?
Back to top
View user's profile Send private message
keopp
Senior Member


Joined: 08 Nov 2008
Posts: 166
Location: Romania

PostPosted: Sun Aug 19, 2012 2:15 pm    Post subject: Reply with quote

SOLVED

It is the "rm -rf" inside the rc.openvpn file:

Code:

...
openvpn_stop() {
    echo "Stoping Openvpn Tunnels"
    killall openvpn 2&>1 /dev/null
    rm -rf $piddir/*.pid
    return 0
}
...


I belive it is enough to replace:
Code:
piddir=/var/run
...
$openvpn --writepid /var/run/`echo $conf | cut -d. -f1`.pid --daemon --config $conf


with

Code:
piddir=/var/run/openvpn
...
$openvpn --writepid $piddir/`echo $conf | cut -d. -f1`.pid --daemon --config $conf


I also belive that the following statements are not sintactically correct as the usage of /dev/null, 2 and 1.

Code:

ls *.pid 1&>2 /dev/null
...
killall openvpn 2&>1 /dev/null

because these are the generators of the files 2 and 1 containing error messages

Searcing for other script examples I found interesting and useful the inclusion of

Code:
/sbin/modprobe tun >/dev/null 2>&1


at the beginning of the rc script.
Back to top
View user's profile Send private message
gerasimos_h
Site Admin


Joined: 09 Aug 2007
Posts: 1757
Location: Greece

PostPosted: Sun Aug 19, 2012 3:40 pm    Post subject: Reply with quote

You are correct, rc.openvpn it's a little messed up, it's my bad to not check it, how it works...
I'll fix it...
An updated package will upload soon along with other upgrades.

Thanks for the bug report...

gerasimos_h

_________________
Superb! Mini Server Project Manager
http://sms.it-ccs.com
Back to top
View user's profile Send private message Visit poster's website
keopp
Senior Member


Joined: 08 Nov 2008
Posts: 166
Location: Romania

PostPosted: Sun Aug 19, 2012 4:46 pm    Post subject: Reply with quote

Ok, I'm glad to help. I use for now the followng working rc.openvpn:

Code:

#!/bin/sh
# Start/stop/restart all the openvpn processes
#by Giancarlo Razzolini

#openvpn binary
openvpn=/usr/sbin/openvpn
#piddir
piddir=/var/run/openvpn
#conf dir
confdir=/etc/openvpn

openvpn_start() {
    echo -n "Starting openvpn: "
    /sbin/modprobe tun >/dev/null 2>&1
    #for all the conf files in the openvpn dir, start a new process
    cd $confdir
    echo "Starting Openvpn Tunnels:"
    for conf in `ls *.conf` ; do
   echo -e "\t$openvpn $confdir/$conf"
   $openvpn --writepid $piddir/`echo $conf | cut -d. -f1`.pid --daemon --config $conf
    done
    return 0
}

openvpn_status() {
    cd $piddir
    ls *.pid > /dev/null 2>&1
    if [ "$?" != "0" ] ; then
   echo "No openvpn process is running."
    else
   for process in `ls *.pid` ; do
       echo Process `cat $process` is running...
   done
    fi
    return 0
}

openvpn_stop() {
    echo "Stoping Openvpn Tunnels"
    killall openvpn > /dev/null 2>&1
    rm -rf $piddir/*.pid
    return 0
}

openvpn_restart() {
    openvpn_stop
    sleep 1
    openvpn_start
}
   
case "$1" in
'start')
   openvpn_start
   ;;
'status')
   openvpn_status
   ;;
'stop')
   openvpn_stop
  ;;
'restart')
   openvpn_restart
   ;;
    *)
   echo "usage $0 start|stop|status|restart"
esac
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    SMS Forum Index » Installation Support All times are GMT + 2 Hours
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
You can attach files in this forum
You can download files in this forum

SMS - Superb! Mini Server Project © 2016
Powered by phpBB © 2001, 2002 phpBB Group
iCGstation v1.0 Template By Ray © 2003, 2004 iOptional