openpkg/rc.openpkg

Wed, 08 Feb 2012 20:07:00 +0200

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 08 Feb 2012 20:07:00 +0200
changeset 588
300d43423c2e
parent 427
71503088f51b
permissions
-rw-r--r--

Update version, adapt patch, correct PID writing, correct build on newer
FreeBSD releases, and most importantly introduce new patch to try to
avoid segfault caused by multiple network interfaces with the same (or
no) address. This is common when configuring bridges and tunnels.

michael@13 1 #!@l_prefix@/bin/openpkg rc
michael@13 2 ##
michael@428 3 ## rc.openpkg -- Run-Commands
michael@428 4 ## Copyright (c) 2000-2012 OpenPKG GmbH <http://openpkg.com/>
michael@428 5 ##
michael@428 6 ## This software is property of the OpenPKG GmbH, DE MUC HRB 160208.
michael@428 7 ## All rights reserved. Licenses which grant limited permission to use,
michael@428 8 ## copy, modify and distribute this software are available from the
michael@428 9 ## OpenPKG GmbH.
michael@428 10 ##
michael@428 11 ## THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
michael@428 12 ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
michael@428 13 ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
michael@428 14 ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
michael@428 15 ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
michael@428 16 ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
michael@428 17 ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
michael@428 18 ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
michael@428 19 ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
michael@428 20 ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
michael@428 21 ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
michael@428 22 ## SUCH DAMAGE.
michael@13 23 ##
michael@13 24
michael@13 25 %config
michael@13 26 openpkg_rc_def="yes"
michael@13 27 openpkg_rc_all="$openpkg_rc_def"
michael@13 28 openpkg_enable="$openpkg_rc_def"
michael@13 29 openpkg_envprio="high"
michael@13 30 openpkg_reghour="3"
michael@13 31 openpkg_regrand="1"
michael@13 32
michael@13 33 %status -o
michael@13 34 openpkg_usable="unknown"
michael@13 35 openpkg_active="unknown"
michael@13 36 echo "openpkg_enable=\"$openpkg_enable\""
michael@13 37 echo "openpkg_usable=\"$openpkg_usable\""
michael@13 38 echo "openpkg_active=\"$openpkg_active\""
michael@13 39
michael@13 40 %info -o
michael@13 41 @l_prefix@/bin/openpkg uuid info
michael@13 42
michael@13 43 %start -p0
michael@13 44 rcService openpkg enable yes || exit 0
michael@428 45
michael@13 46 # update UUID information (in background to not slow down boot sequences)
michael@13 47 (nohup @l_prefix@/bin/openpkg uuid update </dev/null >/dev/null 2>&1 &) >/dev/null 2>&1
michael@13 48
michael@13 49 %hourly -u @l_musr@
michael@13 50 rcService openpkg enable yes || exit 0
michael@428 51
michael@13 52 # automatic (re-)registration
michael@13 53 reregister=0
michael@428 54
michael@13 55 # re-register if previously registered
michael@13 56 @l_prefix@/bin/openpkg register --printstatus >/dev/null 2>&1 && reregister=1
michael@428 57
michael@13 58 # re-register if "openpkg release" configured to pull packages directly from openpkg.(org|com|net)
michael@13 59 [ $reregister -eq 0 ] && @l_prefix@/bin/openpkg release --fmt='%u' \
michael@13 60 | egrep '^[^:]*://(([^:]*:)?([^@]*@)?)?([^/]*\.)?openpkg\.(com|org|net)/' >/dev/null && reregister=1
michael@428 61
michael@13 62 # perform (re-)registration
michael@13 63 if [ $reregister -eq 1 ]; then
michael@13 64 [ $openpkg_reghour -lt 00 -o $openpkg_reghour -gt 23 ] && openpkg_reghour="3"
michael@13 65 now=`date '+%H'`
michael@13 66 [ $openpkg_reghour -eq $now ] || exit 0
michael@13 67 [ $openpkg_regrand -lt 01 -o $openpkg_regrand -gt 04 ] && openpkg_regrand="1"
michael@13 68 rnd=`expr $RANDOM \* 3600 \* $openpkg_regrand / 32768`
michael@13 69 (nohup @l_prefix@/lib/openpkg/bash -c "sleep $rnd; @l_prefix@/bin/openpkg register" </dev/null >/dev/null 2>&1 &) >/dev/null 2>&1
michael@13 70 fi
michael@13 71
michael@13 72 %daily -p0
michael@13 73 rcService openpkg enable yes || exit 0
michael@428 74
michael@13 75 # update UUID information
michael@13 76 @l_prefix@/bin/openpkg uuid update >/dev/null 2>&1 || true
michael@13 77
michael@13 78 %env -p0
michael@13 79 rcService openpkg enable yes || exit 0
michael@13 80
michael@13 81 # determine append (low prio) or prepend (high prio) mode
michael@13 82 opt_prepend=""
michael@13 83 if [ ".$openpkg_envprio" = ".high" ]; then
michael@13 84 opt_prepend="-p"
michael@13 85 fi
michael@13 86
michael@13 87 # make sure the software package executables are found
michael@13 88 export PATH
michael@13 89 rcPath -a -e PATH \
michael@13 90 /bin /sbin /usr/bin /usr/sbin
michael@13 91 rcPath -a ${opt_prepend} PATH \
michael@13 92 @l_prefix@/bin @l_prefix@/sbin \
michael@13 93 @l_prefix@/local/bin @l_prefix@/local/sbin
michael@13 94
michael@13 95 # make sure the software package manual pages are found
michael@13 96 export MANPATH
michael@13 97 rcPath -a -e MANPATH \
michael@13 98 /usr/man /usr/share/man
michael@13 99 rcPath -a ${opt_prepend} MANPATH \
michael@13 100 @l_prefix@/man @l_prefix@/local/man
michael@13 101
michael@13 102 # make sure the software package info pages are found
michael@13 103 export INFOPATH
michael@13 104 rcPath -a -e INFOPATH \
michael@13 105 /usr/info /usr/share/info
michael@13 106 rcPath -a ${opt_prepend} INFOPATH \
michael@13 107 @l_prefix@/info @l_prefix@/local/info
michael@13 108
michael@13 109 # make sure the software package libraries are found
michael@13 110 export LD_LIBRARY_PATH
michael@13 111 rcPath -a -e LD_LIBRARY_PATH \
michael@13 112 /lib /usr/lib
michael@13 113 rcPath -a ${opt_prepend} LD_LIBRARY_PATH \
michael@13 114 @l_prefix@/lib @l_prefix@/local/lib
michael@13 115
michael@13 116 # cleanup
michael@13 117 unset opt_prepend
michael@13 118

mercurial