Changeset 44049 in vbox for trunk/src/VBox/Installer
- Timestamp:
- Dec 6, 2012 11:31:26 AM (12 years ago)
- svn:sync-xref-src-repo-rev:
- 82516
- Location:
- trunk/src/VBox/Installer/linux
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Installer/linux/Makefile.kmk
r43717 r44049 19 19 include $(KBUILD_PATH)/subheader.kmk 20 20 21 # Include sub-makefile. 21 # Include sub-makefiles. 22 include $(PATH_SUB_CURRENT)/install_service/Makefile.kmk 22 23 ifdef VBOX_WITH_TESTCASES 23 24 include $(PATH_SUB_CURRENT)/testcase/Makefile.kmk -
trunk/src/VBox/Installer/linux/install_service/Makefile.kmk
r44002 r44049 1 1 # $Id$ 2 2 ## @file 3 # Sub-Makefile for the VirtualBox Guest Addition X11 Client.3 # Sub-Makefile for the Linux installer init file generator. 4 4 # 5 5 … … 34 34 endif 35 35 36 INSTALLS.linux += linux-install-service-bin 37 linux-install-service-bin_INST = bin/helpers/ 38 linux-install-service-bin_MODE = a+rx,u+w 39 linux-install-service-bin_SOURCES = \ 40 install_service.sh=>install_service 41 42 INSTALLS.linux += linux-install-service-nobin 43 linux-install-service-nobin_INST = bin/helpers/ 44 linux-install-service-nobin_MODE = a+r,u+w 45 linux-install-service-nobin_SOURCES = \ 46 init_template.sh 47 36 48 include $(FILE_KBUILD_SUB_FOOTER) 37 49 -
trunk/src/VBox/Installer/linux/install_service/generate_service_file.cpp
r44002 r44049 89 89 " is supported. This affects escaping of strings substituted.\n" 90 90 "\n" 91 " --command \n"91 " --command <command>\n" 92 92 " The absolute path of the executable file to be started by the service.\n" 93 93 " No form of quoting should be used here. Substituted for the sequence\n" … … 95 95 RTPrintf( 96 96 "\n" 97 " --arguments <arguments>\n"98 " The arguments to pass to the executable file when it is started. ASCII\n"99 " characters 0 to 31, \"\'\" and 127 should be escaped in C string-style and\n"100 " spaces inside words should be preceeded by a back slash. Some systemd-\n"101 " style \"%%\" sequences may be added at a future time. Substituted for the\n"102 " sequence \"%%ARGUMENTS%%\" in the template.\n");103 RTPrintf(104 "\n"105 97 " --description <description>\n" 106 98 " A short description of the service which can also be used in sentences\n" 107 " like \"<description> failed to start.\" . ASCII characters 0 to 31 and 127\n"108 " should not be used. Substituted for the sequence \"%%DESCRIPTION%%\" inthe\n"109 " template.\n"99 " like \"<description> failed to start.\", as a single parameter. ASCII\n" 100 " characters 0 to 31 and 127 should not be used. Substituted for the\n" 101 " sequence \"%%DESCRIPTION%%\" in the template.\n" 110 102 "\n" 111 103 "Other options:\n" 104 "\n"); 105 RTPrintf( 106 " --arguments <arguments>\n" 107 " The arguments to pass to the executable file when it is started, as a\n" 108 " single parameter. ASCII characters 0 to 31, \"\'\" and 127 should be escaped\n" 109 " in C string-style and spaces inside words should be preceeded by a back\n" 110 " slash. Some systemd-style \"%%\" sequences may be added at a future time.\n" 111 " Substituted for the sequence \"%%ARGUMENTS%%\" in the template.\n" 112 112 "\n"); 113 113 RTPrintf( -
trunk/src/VBox/Installer/linux/install_service/init_template.sh
r44002 r44049 23 23 # Short-Description: %DESCRIPTION% 24 24 ### END INIT INFO 25 26 ## @todo We should really replace the daemon starting, stopping and checking 27 # code with a tool of our own written in C, which we could always use 28 # instead of the LSB functions. 25 29 26 30 cr=" … … 71 75 LSB_FUNCTIONS="/lib/lsb/init-functions" 72 76 73 ## Redhat and Fedora lock directory74 LOCK_FOLDER="/var/lock/subsys/"75 LOCK_FILE="${LOCK_FOLDER}/%SERVICE_NAME%"76 77 77 # Silently exit if the package was uninstalled but not purged. 78 [ -r %COMMAND% ]|| exit 078 test -r %COMMAND% || exit 0 79 79 80 80 ## The function definition at the start of every non-trivial shell script! … … 91 91 exit 0 92 92 } 93 94 ## Set the error message. 95 set_error() 96 { 97 test -z "${error}" && error="${1}" 98 } 99 100 # Gentoo/OpenRC perculiarity. 101 if test "x${0}" = "x/sbin/rc" || test "x${0}" = "xrc"; then 102 shift 103 fi 104 105 # Process arguments. 106 action="" 107 error="" 108 prefix="/var" 109 while test x"${#}" != "x0"; do 110 case "${1}" in 111 --lsb-functions) 112 test x"${#}" = "x1" && 113 set_error "${1}: missing argument." 114 LSB_FUNCTIONS="${2}" 115 shift 2;; 116 --prefix) 117 test x"${#}" = "x1" && 118 set_error "${1}: missing argument." 119 prefix="${2}" 120 shift 2;; 121 --help) 122 cat << EOF 123 Usage: 124 125 ${0} {start|stop|restart|status} [<options>] 126 127 start|stop|restart|status 128 Start/stop/restart/report status for the service. 129 130 Options: 131 132 --lsb-functions <script> 133 Take the standard LSB init functions from <script> instead of from the 134 normal location, or use our own versions if <script> is an empty string. 135 136 --prefix <folder> 137 Use the folder <folder> for storing variable data instead of "/var". The 138 child folder "run" must exist. 139 EOF 140 exit 0;; 141 start|stop|restart|force-reload|condrestart|try-restart|reload|status) 142 test -z "${action}" || 143 set_error "More than one action requested." 144 action="${1}" 145 shift;; 146 *) 147 set_error "Unknown option \"${1}\". Try \"${0} --help\" for more information." 148 shift;; 149 esac 150 done 151 152 ## Set Redhat and Fedora lock directory 153 LOCK_FOLDER="${prefix}/lock/subsys/" 154 LOCK_FILE="${LOCK_FOLDER}/%SERVICE_NAME%" 93 155 94 156 # Use LSB functions if available. Success and failure messages default to just 95 157 # "echo" if the LSB functions are not available, so call these functions with 96 158 # messages which clearly read as success or failure messages. 97 [ -n "${LSB_FUNCTIONS}" ] && [ -f "${LSB_FUNCTIONS}" ]&&159 test -n "${LSB_FUNCTIONS}" && test -f "${LSB_FUNCTIONS}" && 98 160 . "${LSB_FUNCTIONS}" 99 161 … … 101 163 log_success_msg() 102 164 { 103 echo "${*}" 104 } 105 106 type log_success_fail >/dev/null 2>&1 || 107 log_success_fail() 108 { 109 echo "${*}" 165 cat << EOF 166 ${*} 167 EOF 168 } 169 170 type log_failure_msg >/dev/null 2>&1 || 171 log_failure_msg() 172 { 173 cat << EOF 174 ${*} 175 EOF 110 176 } 111 177 … … 113 179 pidfilename() 114 180 { 115 echo " /var/run/${1##*/}.pid"181 echo "${prefix}/run/${1##*/}.pid" 116 182 } 117 183 … … 119 185 pidfileofproc() 120 186 { 121 if [ x"${1}" = "x-p" ]; then187 if test x"${1}" = "x-p"; then 122 188 echo "${2}" 123 189 else … … 129 195 pidsfromfile() 130 196 { 131 read -r pids < "${1}" 2>/dev/null 197 pids="" 198 test -r "${1}" && 199 read -r pids < "${1}" 2>/dev/null 132 200 for i in $pids; do 133 [ 1 -le "${i}" ] || return 1 201 test 1 -le "${i}" || return 1 202 done 134 203 echo "${pids}" 135 204 } … … 140 209 binary="${1}" 141 210 shift 142 ps -p "${@}" -f 2>/dev/null | grep -q "${binary}"211 ps -p "${@}" -f 2>/dev/null | grep "${binary}" >/dev/null 143 212 } 144 213 … … 146 215 pidofproc() 147 216 { 148 pidfile=" $(pidfileofproc "${@}")"149 [ "x${1}" = "x-p" ]&& shift 2150 pids=" $(pidsfromfile "${pidfile}")"217 pidfile="`pidfileofproc "${@}"`" 218 test "x${1}" = "x-p" && shift 2 219 pids="`pidsfromfile "${pidfile}"`" 151 220 procrunning "${1}" ${pids} && echo "${pids}" 152 221 } … … 155 224 killproc() 156 225 { 157 pidfile=" $(pidfileofproc "${@}")"158 [ "x${1}" = "x-p" ]&& shift 2159 pids=" $(pidsfromfile "${pidfile}")"160 if [ -n "${2}" ]; then226 pidfile="`pidfileofproc "${@}"`" 227 test "x${1}" = "x-p" && shift 2 228 pids="`pidsfromfile "${pidfile}"`" 229 if test -n "${2}"; then 161 230 procrunning "${1}" ${pids} || return 1 162 231 kill "${2}" ${pids} … … 165 234 rm -f "${pidfile}" 166 235 procrunning "${1}" ${pids} || return 0 167 kill "${pid}" 168 time=0 169 while true; do 170 sleep 1 171 procrunning "${1}" ${pids} || break 172 time=$((${time} + 1)) 173 if [ "${time}" = "${SHUT_DOWN_TIME_OUT}" ]; then 174 kill -9 "${pid}" 175 break 176 fi 236 kill "${pids}" 237 # Short busy wait for the process to terminate. 238 stamp="`times`" 239 while test x"${stamp}" = x"`times`"; do 240 procrunning "${1}" ${pids} || return 0 241 done 242 # Slow sleeping wait if it is still running. 243 for high in "" 1 2 3 4 5 6 7 8 9; do 244 for time in ${high}0 ${high}1 ${high}2 ${high}3 ${high}4 ${high}5 ${high}6 ${high}7 ${high}8 ${high}9; do 245 sleep 1 246 procrunning "${1}" ${pids} || return 0 247 if test "${time}" = "${SHUT_DOWN_TIME_OUT}"; then 248 kill -9 "${pid}" 249 return 0 250 fi 251 done 177 252 done 178 253 return 0 … … 182 257 start() 183 258 { 184 [ -d "${LOCK_FOLDER}" ]&& touch "${LOCK_FILE}"185 [ -n "$(pidofproc %COMMAND%)" ]&& exit 0259 test -d "${LOCK_FOLDER}" && touch "${LOCK_FILE}" 260 test -n "`pidofproc %COMMAND%`" && exit 0 186 261 %COMMAND% %ARGUMENTS% >/dev/null 2>&1 & 187 262 pid="$!" 188 pidfile=" $(pidfilename %COMMAND%)"263 pidfile="`pidfilename %COMMAND%`" 189 264 echo "${pid}" > "${pidfile}" 190 265 do_success … … 201 276 status() 202 277 { 203 [ -n "$(pidofproc %COMMAND%)" ] && exit 0 204 [ -f "$(pidfilename %COMMAND%)" ] && exit 1 205 [ -f "${LOCK_FILE}" ] && exit 2 278 pid="`pidofproc %COMMAND%`" 279 test -n "${pid}" && 280 { 281 echo "%SERVICE_NAME% running, process ${pid}" 282 exit 0 283 } 284 test -f "`pidfilename %COMMAND%`" && 285 { 286 echo "%SERVICE_NAME% not running but PID-file present." 287 exit 1 288 } 289 test -f "${LOCK_FILE}" && 290 { 291 echo "%SERVICE_NAME% not running but lock file present." 292 exit 2 293 } 294 echo "%SERVICE_NAME% not running." 206 295 exit 3 207 296 } 208 297 209 # Gentoo/OpenRC perculiarity. 210 if [ "$(which "${0}")" = "/sbin/rc" ]; then 211 shift 212 fi 213 214 if [ "${1}" = "--lsb-functions" ]; then 215 LSB_FUNCTIONS="${2}" 216 shift 2 217 fi 218 219 case "${1}" in 298 test -z "${error}" || abort "${error}" 299 300 case "${action}" in 220 301 start) 302 start;; 303 stop) 304 stop;; 305 restart|force-reload) 221 306 start 222 ;; 223 stop) 224 stop 225 ;; 226 restart|force-reload) 227 stop 228 start 229 ;; 307 stop;; 230 308 condrestart|try-restart) 231 309 status || exit 0 232 310 stop 233 start 234 ;; 311 start;; 235 312 reload) 236 313 ;; 237 314 status) 238 status 239 ;; 240 *) 241 echo "Usage: ${0} {start|stop|restart|status}" 242 exit 1 315 status;; 243 316 esac -
trunk/src/VBox/Installer/linux/testcase/Makefile.kmk
r43688 r44049 45 45 tstHeadlessXOrg_SOURCES = tstHeadlessXOrg.sh 46 46 47 INSTALLS += tstInstallInit 48 TESTING += tstInstallInit 49 tstHeadlessXOrg_INST = $(INST_TESTCASE) 50 tstHeadlessXOrg_MODE = a+rx,u+w 51 tstHeadlessXOrg_SOURCES = tstInstallInit.sh 52 47 53 include $(FILE_KBUILD_SUB_FOOTER)
Note:
See TracChangeset
for help on using the changeset viewer.