VirtualBox

Ignore:
Timestamp:
Sep 29, 2015 3:21:38 PM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
102920
Message:

Installers/linux: cleaned up init script output and logging a bit.

Location:
trunk/src/VBox/Additions/linux/installer
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/linux/installer/vboxadd-service.sh

    r57732 r57945  
    2727
    2828PATH=$PATH:/bin:/sbin:/usr/sbin
     29SCRIPTNAME=vboxadd-service
    2930
    30 system=unknown
    31 if [ -f /etc/redhat-release ]; then
    32     system=redhat
    33     PIDFILE="/var/lock/subsys/vboxadd-service"
    34 elif [ -f /etc/SuSE-release ]; then
    35     system=suse
    36     PIDFILE="/var/run/vboxadd-service"
    37 elif [ -f /etc/debian_version ]; then
    38     system=debian
    39     PIDFILE="/var/run/vboxadd-service.pid"
    40 elif [ -f /etc/gentoo-release ]; then
    41     system=gentoo
    42     PIDFILE="/var/run/vboxadd-service"
    43 elif [ -f /etc/slackware-version ]; then
    44     system=slackware
    45     PIDFILE="/var/run/vboxadd-service"
    46 elif [ -f /etc/lfs-release ]; then
    47     system=lfs
    48     PIDFILE="/var/run/vboxadd-service.pid"
    49 else
    50     system=other
    51     if [ -d /var/run -a -w /var/run ]; then
    52         PIDFILE="/var/run/vboxadd-service"
    53     fi
     31PIDFILE="/var/run/${SCRIPTNAME}"
     32
     33# Preamble for Gentoo
     34if [ "`which $0`" = "/sbin/rc" ]; then
     35    shift
    5436fi
    5537
    56 if [ "$system" = "redhat" ]; then
    57     . /etc/init.d/functions
    58     fail_msg() {
    59         echo_failure
    60         echo
    61     }
     38begin()
     39{
     40    test -n "${2}" && echo "${SCRIPTNAME}: ${1}."
     41    logger "${SCRIPTNAME}: ${1}."
     42}
    6243
    63     succ_msg() {
    64         echo_success
    65         echo
    66     }
     44succ_msg()
     45{
     46    logger "${SCRIPTNAME}: done."
     47}
    6748
    68     begin() {
    69         echo -n "$1"
    70     }
    71 fi
     49fail_msg()
     50{
     51    echo "${SCRIPTNAME}: failed." >&2
     52    logger "${SCRIPTNAME}: failed."
     53}
    7254
    73 if [ "$system" = "suse" ]; then
    74     . /etc/rc.status
    75     daemon() {
    76         startproc ${1+"$@"}
    77     }
     55daemon() {
     56    $1 $2 $3
     57}
    7858
    79     fail_msg() {
    80         rc_failed 1
    81         rc_status -v
    82     }
     59killproc() {
     60    killall $1
     61    rm -f $PIDFILE
     62}
    8363
    84     succ_msg() {
    85         rc_reset
    86         rc_status -v
    87     }
    88 
    89     begin() {
    90         echo -n "$1"
    91     }
    92 fi
    93 
    94 if [ "$system" = "debian" ]; then
     64if which start-stop-daemon >/dev/null; then
    9565    daemon() {
    9666        start-stop-daemon --start --exec $1 -- $2 $3
     
    9969    killproc() {
    10070        start-stop-daemon --stop --retry 2 --exec $@
    101     }
    102 
    103     fail_msg() {
    104         echo " ...fail!"
    105     }
    106 
    107     succ_msg() {
    108         echo " ...done."
    109     }
    110 
    111     begin() {
    112         echo -n "$1"
    113     }
    114 fi
    115 
    116 if [ "$system" = "gentoo" ]; then
    117     if [ -f /sbin/functions.sh ]; then
    118         . /sbin/functions.sh
    119     elif [ -f /etc/init.d/functions.sh ]; then
    120         . /etc/init.d/functions.sh
    121     fi
    122     daemon() {
    123         start-stop-daemon --start --exec $1 -- $2 $3
    124     }
    125 
    126     killproc() {
    127         start-stop-daemon --stop --retry 2 --exec $@
    128     }
    129 
    130     fail_msg() {
    131         echo " ...fail!"
    132     }
    133 
    134     succ_msg() {
    135         echo " ...done."
    136     }
    137 
    138     begin() {
    139         echo -n "$1"
    140     }
    141 
    142     if [ "`which $0`" = "/sbin/rc" ]; then
    143         shift
    144     fi
    145 fi
    146 
    147 if [ "$system" = "slackware" -o "$system" = "other" ]; then
    148     daemon() {
    149         $1 $2 $3
    150     }
    151 
    152     killproc() {
    153         killall $1
    154         rm -f $PIDFILE
    155     }
    156 
    157     fail_msg() {
    158         echo " ...fail!"
    159     }
    160 
    161     succ_msg() {
    162         echo " ...done."
    163     }
    164 
    165     begin() {
    166         echo -n "$1"
    167     }
    168 
    169 fi
    170 
    171 if [ "$system" = "lfs" ]; then
    172     . /etc/rc.d/init.d/functions
    173     daemon() {
    174         loadproc $1 $2 $3
    175     }
    176 
    177     fail_msg() {
    178         echo_failure
    179     }
    180 
    181     succ_msg() {
    182         echo_ok
    183     }
    184 
    185     begin() {
    186         echo $1
    187     }
    188 
    189     status() {
    190         statusproc $1
    19171    }
    19272fi
     
    20787start() {
    20888    if ! test -f $PIDFILE; then
    209         begin "Starting VirtualBox Guest Addition service ";
     89        begin "Starting VirtualBox Guest Addition service " console;
    21090        vboxaddrunning || {
    21191            echo "VirtualBox Additions module not loaded!"
     
    222102stop() {
    223103    if test -f $PIDFILE; then
    224         begin "Stopping VirtualBox Guest Addition service ";
     104        begin "Stopping VirtualBox Guest Addition service " console;
    225105        killproc $binary
    226106        RETVAL=$?
  • trunk/src/VBox/Additions/linux/installer/vboxadd-x11.sh

    r56860 r57945  
    3333CONFIG_DIR="/var/lib/VBoxGuestAdditions"
    3434CONFIG="config"
     35SCRIPTNAME=vboxadd-x11
    3536
    3637# Check architecture
     
    6970    /usr/X11R6/lib/X11/XF86Config"
    7071
    71 if [ -f /etc/redhat-release ]; then
    72     system=redhat
    73 elif [ -f /etc/debian_version ]; then
    74     system=debian
    75 elif [ -f /etc/SuSE-release ]; then
    76     system=suse
    77 elif [ -f /etc/gentoo-release ]; then
    78     system=gentoo
    79 elif [ -f /etc/lfs-release -a -d /etc/rc.d/init.d ]; then
    80     system=lfs
    81 else
    82     system=other
     72# Preamble for Gentoo
     73if [ "`which $0`" = "/sbin/rc" ]; then
     74    shift
    8375fi
    8476
    85 if [ "$system" = "redhat" ]; then
    86     . /etc/init.d/functions
    87     fail_msg() {
    88         echo_failure
    89         echo
    90     }
    91     succ_msg() {
    92         echo_success
    93         echo
    94     }
    95     begin() {
    96         echo -n "$1"
    97     }
    98 fi
    99 
    100 if [ "$system" = "suse" ]; then
    101     . /etc/rc.status
    102     fail_msg() {
    103         rc_failed 1
    104         rc_status -v
    105     }
    106     succ_msg() {
    107         rc_reset
    108         rc_status -v
    109     }
    110     begin() {
    111         echo -n "$1"
    112     }
    113 fi
    114 
    115 if [ "$system" = "gentoo" ]; then
    116     if [ -f /sbin/functions.sh ]; then
    117         . /sbin/functions.sh
    118     elif [ -f /etc/init.d/functions.sh ]; then
    119         . /etc/init.d/functions.sh
    120     fi
    121     fail_msg() {
    122         eend 1
    123     }
    124     succ_msg() {
    125         eend $?
    126     }
    127     begin() {
    128         ebegin $1
    129     }
    130     if [ "`which $0`" = "/sbin/rc" ]; then
    131         shift
    132     fi
    133 fi
    134 
    135 if [ "$system" = "lfs" ]; then
    136     . /etc/rc.d/init.d/functions
    137     fail_msg() {
    138         echo_failure
    139     }
    140     succ_msg() {
    141         echo_ok
    142     }
    143     begin() {
    144         echo $1
    145     }
    146 fi
    147 
    148 if [ "$system" = "debian" -o "$system" = "other" ]; then
    149     fail_msg() {
    150         echo " ...fail!"
    151     }
    152     succ_msg() {
    153         echo " ...done."
    154     }
    155     begin() {
    156         echo -n $1
    157     }
    158 fi
     77begin()
     78{
     79    test -n "${2}" && echo "${SCRIPTNAME}: ${1}."
     80    logger "${SCRIPTNAME}: ${1}."
     81}
     82
     83succ_msg()
     84{
     85    logger "${SCRIPTNAME}: done."
     86}
     87
     88fail_msg()
     89{
     90    echo "${SCRIPTNAME}: failed." >&2
     91    logger "${SCRIPTNAME}: failed."
     92}
    15993
    16094dev=/dev/vboxguest
     
    16599fail()
    166100{
    167     if [ "$system" = "gentoo" ]; then
    168         eerror $1
    169         exit 1
    170     fi
    171     fail_msg
    172     echo "($1)"
     101    echo "${SCRIPTNAME}: failed: ${1}." >&2
     102    logger "${SCRIPTNAME}: ${1}."
    173103    exit 1
    174104}
  • trunk/src/VBox/Additions/linux/installer/vboxadd.sh

    r57589 r57945  
    3434MODPROBE=/sbin/modprobe
    3535OLDMODULES="vboxguest vboxadd vboxsf vboxvfs vboxvideo"
     36SCRIPTNAME=vboxadd
    3637
    3738if $MODPROBE -c 2>/dev/null | grep -q '^allow_unsupported_modules  *0'; then
     
    5859done
    5960
    60 if [ -f /etc/redhat-release ]; then
    61     system=redhat
    62 elif [ -f /etc/SuSE-release ]; then
    63     system=suse
    64 elif [ -f /etc/gentoo-release ]; then
    65     system=gentoo
    66 elif [ -f /etc/lfs-release -a -d /etc/rc.d/init.d ]; then
    67     system=lfs
    68 else
    69     system=other
     61# Preamble for Gentoo
     62if [ "`which $0`" = "/sbin/rc" ]; then
     63    shift
    7064fi
    7165
    72 if [ "$system" = "redhat" ]; then
    73     . /etc/init.d/functions
    74     fail_msg() {
    75         echo_failure
    76         echo
    77     }
    78     succ_msg() {
    79         echo_success
    80         echo
    81     }
    82     begin() {
    83         echo -n "$1"
    84     }
    85 fi
    86 
    87 if [ "$system" = "suse" ]; then
    88     . /etc/rc.status
    89     fail_msg() {
    90         rc_failed 1
    91         rc_status -v
    92     }
    93     succ_msg() {
    94         rc_reset
    95         rc_status -v
    96     }
    97     begin() {
    98         echo -n "$1"
    99     }
    100 fi
    101 
    102 if [ "$system" = "gentoo" ]; then
    103     if [ -f /sbin/functions.sh ]; then
    104         . /sbin/functions.sh
    105     elif [ -f /etc/init.d/functions.sh ]; then
    106         . /etc/init.d/functions.sh
    107     fi
    108     fail_msg() {
    109         eend 1
    110     }
    111     succ_msg() {
    112         eend $?
    113     }
    114     begin() {
    115         ebegin $1
    116     }
    117     if [ "`which $0`" = "/sbin/rc" ]; then
    118         shift
    119     fi
    120 fi
    121 
    122 if [ "$system" = "lfs" ]; then
    123     . /etc/rc.d/init.d/functions
    124     fail_msg() {
    125         echo_failure
    126     }
    127     succ_msg() {
    128         echo_ok
    129     }
    130     begin() {
    131         echo $1
    132     }
    133 fi
    134 
    135 if [ "$system" = "other" ]; then
    136     fail_msg() {
    137         echo " ...fail!"
    138     }
    139     succ_msg() {
    140         echo " ...done."
    141     }
    142     begin() {
    143         echo -n $1
    144     }
    145 fi
     66begin()
     67{
     68    test -n "${2}" && echo "${SCRIPTNAME}: ${1}."
     69    logger "${SCRIPTNAME}: ${1}."
     70}
     71
     72succ_msg()
     73{
     74    logger "${SCRIPTNAME}: done."
     75}
     76
     77fail_msg()
     78{
     79    echo "${SCRIPTNAME}: failed." >&2
     80    logger "${SCRIPTNAME}: failed."
     81}
    14682
    14783show_error()
    14884{
    149     if [ "$system" = "gentoo" ]; then
    150         eerror $1
    151     fi
    152     fail_msg
    153     echo "($1)"
     85    echo "${SCRIPTNAME}: failed: ${1}." >&2
     86    logger "${SCRIPTNAME}: ${1}."
    15487}
    15588
     
    183116    fi
    184117    printf "\nThe headers for the current running kernel were not found. If the following\nmodule compilation fails then this could be the reason.\n"
    185     if [ "$system" = "redhat" ]; then
     118    if which yum >/dev/null; then
    186119        if echo "$KERN_VER" | grep -q "uek"; then
    187120            printf "The missing package can be probably installed with\nyum install kernel-uek-devel-$KERN_VER\n"
     
    189122            printf "The missing package can be probably installed with\nyum install kernel-devel-$KERN_VER\n"
    190123        fi
    191     elif [ "$system" = "suse" ]; then
     124    elif which zypper >/dev/null; then
    192125        KERN_VER_SUSE=`echo "$KERN_VER" | sed 's/.*-\([^-]*\)/\1/g'`
    193126        KERN_VER_BASE=`echo "$KERN_VER" | sed 's/\(.*\)-[^-]*/\1/g'`
    194127        printf "The missing package can be probably installed with\nzypper install kernel-$KERN_VER_SUSE-devel-$KERN_VER_BASE\n"
    195     elif [ "$system" = "debian" ]; then
     128    elif which apt-get >/dev/null; then
    196129        printf "The missing package can be probably installed with\napt-get install linux-headers-$KERN_VER\n"
    197130    fi
     
    268201start()
    269202{
    270     begin "Starting the VirtualBox Guest Additions ";
     203    begin "Starting the VirtualBox Guest Additions" console;
    271204    uname -r | grep -q -E '^2\.6|^3|^4' 2>/dev/null &&
    272205        ps -A -o comm | grep -q '/*udevd$' 2>/dev/null ||
     
    318251stop()
    319252{
    320     begin "Stopping VirtualBox Additions ";
     253    begin "Stopping VirtualBox Additions" console;
    321254    if ! umount -a -t vboxsf 2>/dev/null; then
    322255        fail "Cannot unmount vboxsf folders"
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette