Changeset 1191


Ignore:
Timestamp:
Jan 4, 2009, 3:24:38 PM (10 years ago)
Author:
jrollins
Message:

runit: fix some bashisms in run scripts, and general clean up of the
scripts.

Location:
trunk/runit/servicedirs
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/runit/servicedirs/atftpd/run

    r967 r1191  
    1 #!/bin/sh
     1#!/bin/sh -e
    22exec 2>&1
     3
     4if [ -z "$RUN" ] ; then
     5    export RUN=0
     6    exec chpst -e ./env ./run
     7fi
    38
    49OPTIONS="--daemon --no-fork --logfile /dev/stdout --tftpd-timeout 30 --retry-timeout 5 --no-tsize --no-blksize --no-multicast --maxthread 1000 --verbose=7"
    510export OPTIONS
    611
    7 run_tftpd() {
    8     # check that root directory exists
    9     if [ ! -d "$ROOT" ] ; then
    10         echo "ROOT directory '$ROOT' does not exist."
    11         exit 1
    12     fi
    13     # check if address is specified
    14     if [ "$ADDRESS" ] ; then
    15         OPTIONS="$OPTIONS --bind-address $ADDRESS"
    16     fi
    17     # check if port is specified
    18     if [ "$PORT" ] ; then
    19         OPTIONS="$OPTIONS --port $PORT"
    20     fi
    21     # check if user is specified
    22     if [ "$USER" ] ; then
    23         OPTIONS="$OPTIONS --user $USER"
    24     fi
    25     # check if group is specified
    26     if [ "$GROUP" ] ; then
    27         OPTIONS="$OPTIONS --group $GROUP"
    28     fi
    29     echo "starting atftpd:"
    30     echo "in.tftpd $OPTIONS $ROOT"
    31     exec in.tftpd $OPTIONS "$ROOT"
    32 }
    33 export -f run_tftpd
     12# check that root directory exists
     13if [ ! -d "$ROOT" ] ; then
     14    echo "ROOT directory '$ROOT' does not exist."
     15    exit 1
     16fi
     17# check if address is specified
     18[ "$ADDRESS" ] && OPTIONS="$OPTIONS --bind-address $ADDRESS"
     19# check if port is specified
     20[ "$PORT" ] && OPTIONS="$OPTIONS --port $PORT"
     21# check if user is specified
     22[ "$USER" ] && OPTIONS="$OPTIONS --user $USER"
     23# check if group is specified
     24[ "$GROUP" ] && OPTIONS="$OPTIONS --group $GROUP"
    3425
    35 exec chpst -e ./env sh -c run_tftpd
     26echo "starting atftpd:"
     27echo "in.tftpd $OPTIONS $ROOT"
     28exec in.tftpd $OPTIONS "$ROOT"
  • trunk/runit/servicedirs/dhclient/run

    r975 r1191  
    1 #!/bin/sh
     1#!/bin/sh -e
    22exec 2>&1
    33
    4 run_dhclient() {
    5     exec dhclient -d $INTERFACES
    6 }
    7 export -f run_dhclient
     4if [ ! -s env/INTERFACES ] ; then
     5    echo "no interfaces specified."
     6    exit 1
     7fi
    88
    99# check that the interface exists before running
    1010for iface in $(cat env/INTERFACES) ; do
    11     ip addr show $iface > /dev/null || exit 1
     11    ip addr show $iface > /dev/null
    1212done
    1313
    14 exec chpst -e ./env sh -c run_dhclient
     14exec chpst -e ./env sh -c 'exec dhclient -d $INTERFACES'
  • trunk/runit/servicedirs/dhcp/run

    r808 r1191  
    11#!/bin/sh
    22exec 2>&1
    3 exec chpst -e ./env dhcpd -f -d $INTERFACES
     3exec chpst -e ./env sh -c 'exec dhcpd -f -d $INTERFACES'
  • trunk/runit/servicedirs/gpm/run

    r816 r1191  
    1 #!/bin/sh
     1#!/bin/sh -e
    22exec 2>&1
    33
     
    66CFG=/etc/gpm.conf
    77
    8 test -x $GPM || exit 0
     8test -x $GPM || exit 1
    99
    1010cmdln=
     
    1313if [ -f $CFG ]; then
    1414  . $CFG
    15   if [ -n "$device" ]; then cmdln="$cmdln -m $device"; fi
    16   if [ -n "$type" ]; then cmdln="$cmdln -t $type"; fi
    17   if [ -n "$responsiveness" ]; then cmdln="$cmdln -r $responsiveness"; fi
    18   if [ -n "$sample_rate" ]; then cmdln="$cmdln -s $sample_rate"; fi
     15  [ -n "$device" ] && cmdln="$cmdln -m $device"
     16  [ -n "$type" ] && cmdln="$cmdln -t $type"
     17  [ -n "$responsiveness" ] && cmdln="$cmdln -r $responsiveness"
     18  [ -n "$sample_rate" ] && cmdln="$cmdln -s $sample_rate"
     19
    1920  # Yes, this /IS/ correct! There is no space after -R!!!!!!
    2021  # I reserve the right to throw manpages at anyone who disagrees.
    21   if [ -n "$repeat_type" ] && [ "$repeat_type" != "none" ]; then
    22     cmdln="$cmdln -R$repeat_type"
    23   fi
    24   if [ -n "$append" ]; then cmdln="$cmdln $append"; fi
     22  [ -n "$repeat_type" ] && [ "$repeat_type" != "none" ] && \
     23      cmdln="$cmdln -R$repeat_type"
     24  [ -n "$append" ] && cmdln="$cmdln $append"
     25
    2526  # If both the second device and type are specified, use it.
    26   if [ -n "$device2" ] && [ -n "$type2" ] ; then
    27     cmdln="$cmdln -M -m $device2 -t $type2"
    28   fi
     27  [ -n "$device2" ] && [ -n "$type2" ] && \
     28      cmdln="$cmdln -M -m $device2 -t $type2"
    2929fi
    3030
  • trunk/runit/servicedirs/mpd/run

    r812 r1191  
    1 #!/bin/sh
     1#!/bin/sh -e
    22exec 2>&1
    33
     
    66MPD_OPTS="--no-daemon --stdout"
    77
    8 if [ -r /etc/default/mpd ]; then
    9     . /etc/default/mpd
     8echo "Starting Music Player Daemon: "
     9
     10[ -r /etc/default/mpd ] && . /etc/default/mpd
     11
     12# check the config
     13if ! (grep -q db_file $MPDCONF && grep -q pid_file $MPDCONF); then
     14    echo "$MPDCONF must have db_file and pid_file set; not starting."
     15    exit 1
    1016fi
    1117
    12 check_conf () {
    13     if ! (grep -q db_file $MPDCONF && grep -q pid_file $MPDCONF); then
    14         echo "$MPDCONF must have db_file and pid_file set; not starting."
    15         exit 0
    16     fi
    17 }
     18# check the db file
     19DBFILE=`sed -n -e 's/^[[:space:]]*db_file[[:space:]]*"\?\([^"]*\)\"\?/\1/p' $MPDCONF`
     20if [ ! -f "$DBFILE" ]; then
     21    echo "creating $DBFILE... "
     22    $DAEMON --create-db "$MPDCONF" > /dev/null
     23fi
    1824
    19 check_dbfile () {
    20     DBFILE=`sed -n -e 's/^[[:space:]]*db_file[[:space:]]*"\?\([^"]*\)\"\?/\1/p' $MPDCONF`
    21     if [ ! -f "$DBFILE" ]; then
    22         echo "creating $DBFILE... "
    23         $DAEMON --create-db "$MPDCONF" > /dev/null
    24     fi
    25 }
    26 
    27 echo "Starting Music Player Daemon: "
    28 check_conf
    29 check_dbfile
    3025exec chpst -u mpd $DAEMON $MPD_OPTS "$MPDCONF"
  • trunk/runit/servicedirs/ntp/run

    r972 r1191  
    1 #!/bin/sh
     1#!/bin/sh -e
    22exec 2>&1
    33
    4 if [ -f /etc/default/ntp ] ; then
    5     . /etc/default/ntp
    6 fi
     4[ -f /etc/default/ntp ] && . /etc/default/ntp
    75
    86echo "starting ntpd..."
  • trunk/runit/servicedirs/nullmailer/run

    r874 r1191  
    1 #!/bin/sh
     1#!/bin/sh -e
    22exec 2>&1
    33
  • trunk/runit/servicedirs/ssh/run

    r972 r1191  
    1 #!/bin/sh
     1#!/bin/sh -e
    22exec 2>&1
    33
    4 if [ -f /etc/default/ssh ] ; then
    5     . /etc/default/ssh
    6 fi
     4[ -f /etc/default/ssh ] && . /etc/default/ssh
    75
    86# make sure priviledge seperation chroot directory exists
  • trunk/runit/servicedirs/tftpd-hpa/run

    r967 r1191  
    1 #!/bin/sh
     1#!/bin/sh -e
    22exec 2>&1
     3
     4if [ -z "$RUN" ] ; then
     5    export RUN=0
     6    exec chpst -e ./env ./run
     7fi
    38
    49OPTIONS="-L -s -v"
    510export OPTIONS
    611
    7 run_tftpd() {
    8     # check that root directory exists
    9     if [ ! -d "$ROOT" ] ; then
    10         echo "ROOT directory '$ROOT' does not exist."
    11         exit 1
    12     fi
    13     # check if address is specified
    14     if [ "$ADDRESS" ] ; then
    15         OPTIONS="$OPTIONS -a $ADDRESS"
    16     fi
    17     if [ "$USER" ] ; then
    18         OPTIONS="$OPTIONS -u $USER"
    19     fi
    20     echo "starting tftpd-hpa:"
    21     echo "in.tftpd $OPTIONS $ROOT"
    22     exec in.tftpd $OPTIONS "$ROOT"
    23 }
    24 export -f run_tftpd
     12# check that root directory exists
     13if [ ! -d "$ROOT" ] ; then
     14    echo "ROOT directory '$ROOT' does not exist."
     15    exit 1
     16fi
     17# check if address is specified
     18[ "$ADDRESS" ] && OPTIONS="$OPTIONS -a $ADDRESS"
     19# check if user is specified
     20[ "$USER" ] && OPTIONS="$OPTIONS -u $USER"
    2521
    26 exec chpst -e ./env sh -c run_tftpd
     22echo "starting tftpd-hpa:"
     23echo "in.tftpd $OPTIONS $ROOT"
     24exec in.tftpd $OPTIONS "$ROOT"
Note: See TracChangeset for help on using the changeset viewer.