🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: alt.privacy.anon-server
3 messages
3 total messages Started by Anonymous Remailer (austria) Fri, 15 Jul 2016 16:17
Problem with mixmaster init.d script
#283442
Author: Anonymous Remailer (austria)
Date: Fri, 15 Jul 2016 16:17
107 lines
2794 bytes
  Every time I try to run this auto start script, if gets this error:

Detaching.
Could not open pidfile for readwrite: Permission denied
Aborting.

  The problem is that it changes the mixmaster.pid file ownership to root:root.  Does anyonec see a way around this:

Script:

#!/bin/sh
### name = mixmaster

dir="/home/mix/Mix"
cmd="./mixmaster -D"
user="mix"

name=`basename $0`
pid_file="$dir/$name.pid"

#VERBOSE=0
#BASEDIR="/home/$user/Mix"
#MIXEXE="$BASEDIR/mixmaster"

stdout_log="/var/log/$name.log"
stderr_log="/var/log/$name.err"


get_pid() {
    cat "$pid_file"
}

is_running() {
    [ -f "$pid_file" ] && ps `get_pid` > /dev/null 2>&1
}

case "$1" in
    start)
    if is_running; then
       echo "Already started"
       else
       echo "Starting $name"
       cd "$dir"
       if [ -z "$user" ]; then
          sudo $cmd >> "$stdout_log" 2>> "$stderr_log" &
          else
          sudo -u "$user" $cmd >> "$stdout_log" 2>> "$stderr_log" &
       fi
       echo $! > "$pid_file"
       if ! is_running; then
          echo "Unable to start, see $stdout_log and $stderr_log"
          exit 1
       fi
    fi
    ;;
    stop)
    if is_running; then
        echo -n "Stopping $name.."
        kill `get_pid`
        for i in {1..10}
        do
            if ! is_running; then
               break
            fi

            echo -n "."
            sleep 1
        done
        echo

        if is_running; then
            echo "Not stopped; may still be shutting down or shutdown may have failed"
            exit 1
        else
            echo "Stopped"
            if [ -f "$pid_file" ]; then
                rm "$pid_file"
            fi
        fi
    else
        echo "Not running"
    fi
    ;;
    restart)
    $0 stop
    if is_running; then
        echo "Unable to stop, will not attempt to start"
        exit 1
    fi
    $0 start
    ;;
    status)
    if is_running; then
       echo "Running"
    else
       echo "Stopped"
       exit 1
    fi
    ;;
    *)
    echo "Usage: $0 {start|stop|restart|status}"
    exit 1
    ;;
esac

exit 0
Re: Problem with mixmaster init.d script
#283443
Author: Anonymous
Date: Fri, 15 Jul 2016 22:47
156 lines
5022 bytes
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

> Every time I try to run this auto start script, if gets
> this error:
> 
> Detaching.
> Could not open pidfile for readwrite: Permission denied
> Aborting.
> 
> The problem is that it changes the mixmaster.pid file
> ownership to root:root.  Does anyonec see a way around this:

  I have been needing to create one of these for myself,
so I rewrote it.  It seems to be working ok.  The problem
you were having seemed to be with an unnecessary instruction
that was being executed from root that was causing root to
take ownership of the mixmaster.pid file.  The below works
when executed directly.  I have not tried to see if it will
correctly auto start mixmaster at boot.

#!/bin/sh
#
# Usage: /etc/init.d/mixmaster.sh <start|stop|restart|status>
#
# Name of this program should be: 'mixmaster.sh'.  Do not name it 'mixmaster'
# because the 'is_running()' function becomes confused.
# Place the script in the /etc/init.d/ folder.
# Name of the program that this program controls ('mixmaster' in this case)
# should be placed in the 'pgmname' field.
# dir is the path to the 'mixmaster' executable.
# user is the user running 'mixmaster'.
# cmd is the command used to execute 'mixmaster'.

dir="/home/mix/Mix"
cmd="./mixmaster -D"
user="mix"
pgmname="mixmaster"

pid_file="$dir/$pgmname.pid"

stdout_log="/var/log/$pgmname.log"
stderr_log="/var/log/$pgmname.err"

get_pid() {
    cat "$pid_file"
}

is_running() {
if pidof -x "$pgmname" >/dev/null; then
   return 0
   else
   return 1
fi}

case "$1" in
   start)
    if is_running; then
       echo "Already started"
    else
       echo "Starting $pgmname"
       cd "$dir"
       if [ -z "$user" ]; then
          sudo $cmd >> "$stdout_log" 2>> "$stderr_log" &
          else
          sudo -u "$user" $cmd >> "$stdout_log" 2>> "$stderr_log" &
       fi

       if ! is_running; then
           for i in {1..10}; do
               if is_running; then
                  echo ""
                  echo "Started!"
                  break
               fi

               echo -n "."
               sleep 1
           done
       fi

       if ! is_running; then
          echo "Unable to start, see $stdout_log and $stderr_log"
          exit 1
       fi
    fi
    ;;

   stop)
    if is_running; then
        echo -n "Stopping $pgmname.."
        kill `get_pid`
        for i in {1..10}; do
            if ! is_running; then
               echo ""
               break
            fi

            echo -n "."
            sleep 1
        done
        echo

        if is_running; then
            echo "Not stopped - may still be shutting down or shutdown may have failed."
            exit 1
        else
            echo "Stopped!"
        fi
    else
        echo "Not running."
    fi
    ;;

   restart)
    $0 stop
    if is_running; then
        echo "Unable to stop, will not attempt to restart."
        exit 1
    fi
    $0 start
    ;;
    status)
    if is_running; then
       echo "Running!"
    else
       echo "Stopped!"
       exit 1
    fi
    ;;
    *)
    echo "Usage: $0 {start|stop|restart|status}"
    exit 1
    ;;
esac

exit 0

-----BEGIN PGP SIGNATURE-----

iQIcBAEBAgAGBQJXiVbxAAoJEInjXwVU+GB4XT0QAIFkFxKXf/9zzpnTMevYo99l
REz+N8WI0jkHQOA2QOrQrkW9b91dJJZiaQNptG958gJ03ugK1t6Zyx7JeLVi9ZRZ
zeXSJIMB7ejLuIQvoE9g/lZihumzgUaxSEa6HUgt9UYDeHc2t6mE6BP5qefEIaB4
mMV2I3NO6HvVwIE1+hmBF5aOrHpRtBUgolApMpl1VEY6M5+ruumPEv2gujwIZcIT
c8HH6K5Nlzl4V+i79B6Llsvq6AnbPLVY4wI4uXT3mlGhhrDjXzt71ij0xEcnDBiy
3GtLwfO70V6NtOxUsUdzGjKuSp9vIThpvjiwL2YNJAcnRL9craj8nQeACSyJuZxp
4xp6b8dLXTYYOJOCCZ+fDGnUv1xbst6GwMDRKn736Yg070szhPHhX6pvEnMkaMV2
16Ut//N2sz9dvEC6i54XErtLmJMxJX9N9kY+FsEuTaEUmb7031hwDCii0CkY3LO3
SemaEA38ZqFcdd/Q37gomnaFxb2jfJTEIeKAcSwKGBuvJ8lMlWpREBYPZhvU62yp
U1m39ftxHl3Bigh0c4gz/IvcBZ8EocGKj8j8EIhT4pSmoqYDnfc7Q8ike2Z9tBlN
BJMFHBCRMQ37K6vcbwoZvsgYjM0DPDFove4KElO8BvOzMqDncnNTUea0J90D5gIG
yoXY/NspahV1X/9LpHw6
=fFq7
-----END PGP SIGNATURE-----

inwtx.net
Re: Problem with mixmaster init.d script
#283458
Author: Jeremy Bentham
Date: Sun, 17 Jul 2016 02:13
105 lines
2724 bytes
> Every time I try to run this auto start script, if gets this error:
> 
> Detaching.
> Could not open pidfile for readwrite: Permission denied
> Aborting.
> 
> The problem is that it changes the mixmaster.pid file ownership to root:root.  Does anyonec see a way around this:
> 
> Script:
> 
> #!/bin/sh
> ### name = mixmaster
> 
> dir="/home/mix/Mix"
> cmd="./mixmaster -D"
> user="mix"
> 
> name=`basename $0`
> pid_file="$dir/$name.pid"
> 
> #VERBOSE=0
> #BASEDIR="/home/$user/Mix"
> #MIXEXE="$BASEDIR/mixmaster"
> 
> stdout_log="/var/log/$name.log"
> stderr_log="/var/log/$name.err"
> 
> 
> get_pid() {
> cat "$pid_file"
> }
> 
> is_running() {
> }
> 
> case "$1" in
> start)
> if is_running; then
> echo "Already started"
> else
> echo "Starting $name"
> cd "$dir"
> sudo $cmd >> "$stdout_log" 2>> "$stderr_log" &
> else
> sudo -u "$user" $cmd >> "$stdout_log" 2>> "$stderr_log" &
> fi
> echo $! > "$pid_file"
> if ! is_running; then
> echo "Unable to start, see $stdout_log and $stderr_log"
> exit 1
> fi
> fi
> ;;
> stop)
> if is_running; then
> echo -n "Stopping $name.."
> kill `get_pid`
> for i in {1..10}
> do
> if ! is_running; then
> break
> fi
> 
> echo -n "."
> sleep 1
> done
> echo
> 
> if is_running; then
> echo "Not stopped; may still be shutting down or shutdown may have failed"
> exit 1
> else
> echo "Stopped"
> rm "$pid_file"
> fi
> fi
> else
> echo "Not running"
> fi
> ;;
> restart)
> $0 stop
> if is_running; then
> echo "Unable to stop, will not attempt to start"
> exit 1
> fi
> $0 start
> ;;
> status)
> if is_running; then
> echo "Running"
> else
> echo "Stopped"
> exit 1
> fi
> ;;
> *)
> echo "Usage: $0 {start|stop|restart|status}"
> exit 1
> ;;
> esac
> 
> exit 0

  Thank you.  Working here too.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads