Changeset 30163


Ignore:
Timestamp:
2012-02-05T04:13:05+01:00 (4 years ago)
Author:
jow
Message:

[backfire] base-files: backport r28834, r28857, r28864, r28865, r28870, r28871, r28991

Location:
branches/backfire/package/base-files
Files:
1 added
2 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/backfire/package/base-files/Makefile

    r29933 r30163  
    1111 
    1212PKG_NAME:=base-files 
    13 PKG_RELEASE:=43.32 
     13PKG_RELEASE:=43.33 
    1414 
    1515PKG_FILE_DEPENDS:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/ 
  • branches/backfire/package/base-files/files/etc/rc.common

    r20571 r30163  
    11#!/bin/sh 
    2 # Copyright (C) 2006-2009 OpenWrt.org 
     2# Copyright (C) 2006-2011 OpenWrt.org 
    33 
    44. $IPKG_INSTROOT/etc/functions.sh 
  • branches/backfire/package/base-files/files/lib/functions.sh

    r28857 r30163  
    11#!/bin/sh 
    2 # Copyright (C) 2006 OpenWrt.org 
     2# Copyright (C) 2006-2011 OpenWrt.org 
    33# Copyright (C) 2006 Fokus Fraunhofer <carsten.tittel@fokus.fraunhofer.de> 
    44 
     
    276276} 
    277277 
     278# 
     279# service: simple wrapper around start-stop-daemon 
     280# 
     281# Usage: service ACTION EXEC ARGS... 
     282# 
     283# Action: 
     284#   -C   check if EXEC is alive 
     285#   -S   start EXEC, passing it ARGS as its arguments 
     286#   -K   kill EXEC, sending it a TERM signal if not specified otherwise 
     287# 
     288# Environment variables exposed: 
     289#   SERVICE_DAEMONIZE    run EXEC in background 
     290#   SERVICE_WRITE_PID    create a pid-file and use it for matching 
     291#   SERVICE_MATCH_EXEC   use EXEC command-line for matching (default) 
     292#   SERVICE_MATCH_NAME   use EXEC process name for matching 
     293#   SERVICE_USE_PID      assume EXEC create its own pid-file and use it for matching 
     294#   SERVICE_NAME         process name to use (default to EXEC file part) 
     295#   SERVICE_PID_FILE     pid file to use (default to /var/run/$SERVICE_NAME.pid) 
     296#   SERVICE_SIG          signal to send when using -K 
     297#   SERVICE_SIG_RELOAD   default signal used when reloading 
     298#   SERVICE_SIG_STOP     default signal used when stopping 
     299#   SERVICE_STOP_TIME    time to wait for a process to stop gracefully before killing it 
     300#   SERVICE_UID          user EXEC should be run as 
     301#   SERVICE_GID          group EXEC should be run as 
     302# 
     303#   SERVICE_DEBUG        don't do anything, but show what would be done 
     304#   SERVICE_QUIET        don't print anything 
     305# 
     306 
     307SERVICE_QUIET=1 
     308SERVICE_SIG_RELOAD="HUP" 
     309SERVICE_SIG_STOP="TERM" 
     310SERVICE_STOP_TIME=5 
     311SERVICE_MATCH_EXEC=1 
     312 
     313service() { 
     314        local ssd 
     315        local exec 
     316        local name 
     317        local start 
     318        ssd="${SERVICE_DEBUG:+echo }start-stop-daemon${SERVICE_QUIET:+ -q}" 
     319        case "$1" in 
     320          -C) 
     321                ssd="$ssd -K -t" 
     322                ;; 
     323          -S) 
     324                ssd="$ssd -S${SERVICE_DAEMONIZE:+ -b}${SERVICE_WRITE_PID:+ -m}" 
     325                start=1 
     326                ;; 
     327          -K) 
     328                ssd="$ssd -K${SERVICE_SIG:+ -s $SERVICE_SIG}" 
     329                ;; 
     330          *) 
     331                echo "service: unknown ACTION '$1'" 1>&2 
     332                return 1 
     333        esac 
     334        shift 
     335        exec="$1" 
     336        [ -n "$exec" ] || { 
     337                echo "service: missing argument" 1>&2 
     338                return 1 
     339        } 
     340        [ -x "$exec" ] || { 
     341                echo "service: file '$exec' is not executable" 1>&2 
     342                return 1 
     343        } 
     344        name="${SERVICE_NAME:-${exec##*/}}" 
     345        [ -z "$SERVICE_USE_PID$SERVICE_WRITE_PID$SERVICE_PID_FILE" ] \ 
     346                || ssd="$ssd -p ${SERVICE_PID_FILE:-/var/run/$name.pid}" 
     347        [ -z "$SERVICE_MATCH_NAME" ] || ssd="$ssd -n $name" 
     348        ssd="$ssd${SERVICE_UID:+ -c $SERVICE_UID${SERVICE_GID:+:$SERVICE_GID}}" 
     349        [ -z "$SERVICE_MATCH_EXEC$start" ] || ssd="$ssd -x $exec" 
     350        shift 
     351        $ssd${1:+ -- "$@"} 
     352} 
     353 
     354service_check() { 
     355        service -C "$@" 
     356} 
     357 
     358service_signal() { 
     359        SERVICE_SIG="${SERVICE_SIG:-USR1}" service -K "$@" 
     360} 
     361 
     362service_start() { 
     363        service -S "$@" 
     364} 
     365 
     366service_stop() { 
     367        local try 
     368        SERVICE_SIG="${SERVICE_SIG:-$SERVICE_SIG_STOP}" service -K "$@" || return 1 
     369        while [ $((try++)) -lt $SERVICE_STOP_TIME ]; do 
     370                service -C "$@" || return 0 
     371                sleep 1 
     372        done 
     373        SERVICE_SIG="KILL" service -K "$@" 
     374        sleep 1 
     375        ! service -C "$@" 
     376} 
     377 
     378service_reload() { 
     379        SERVICE_SIG="${SERVICE_SIG:-$SERVICE_SIG_RELOAD}" service -K "$@" 
     380} 
     381 
    278382service_kill() { 
     383        cat 1>&2 << __END_OF_WARNING__ 
     384# 
     385# WARNING: the 'service_kill' function is now deprecated and might be  
     386# removed soon. Consider using the other new service_* wrappers instead. 
     387# 
     388__END_OF_WARNING__ 
    279389        local name="${1}" 
    280390        local pid="${2:-$(pidof "$name")}" 
     
    291401                        while grep -qs "$name" "/proc/$pid/cmdline"; do sleep 1; done 
    292402        done 
     403} 
     404 
     405 
     406group_add() { 
     407        local name="$1" 
     408        local gid="$2" 
     409        local rc 
     410        [ -f "${IPKG_INSTROOT}/etc/group" ] || return 1 
     411        [ -n "$IPKG_INSTROOT" ] || lock /var/lock/group 
     412        echo "${name}:x:${gid}:" >> ${IPKG_INSTROOT}/etc/group 
     413        rc=$? 
     414        [ -n "$IPKG_INSTROOT" ] || lock -u /var/lock/group 
     415        return $rc 
     416} 
     417 
     418group_exists() { 
     419        grep -qs "^${1}:" ${IPKG_INSTROOT}/etc/group 
     420} 
     421 
     422user_add() { 
     423        local name="${1}" 
     424        local uid="${2}" 
     425        local gid="${3:-$2}" 
     426        local desc="${4:-$1}" 
     427        local home="${5:-/var/run/$1}" 
     428        local shell="${6:-/bin/false}" 
     429        local rc 
     430        [ -f "${IPKG_INSTROOT}/etc/passwd" ] || return 1 
     431        [ -n "$IPKG_INSTROOT" ] || lock /var/lock/passwd 
     432        echo "${name}:x:${uid}:${gid}:${desc}:${home}:${shell}" >> ${IPKG_INSTROOT}/etc/passwd 
     433        rc=$? 
     434        [ -n "$IPKG_INSTROOT" ] || lock -u /var/lock/passwd 
     435        return $rc 
     436} 
     437 
     438user_exists() { 
     439        grep -qs "^${1}:" ${IPKG_INSTROOT}/etc/passwd 
    293440} 
    294441 
Note: See TracChangeset for help on using the changeset viewer.