Changeset 98609 in vbox for trunk/src/VBox/Additions/linux
- Timestamp:
- Feb 16, 2023 4:33:36 PM (2 years ago)
- svn:sync-xref-src-repo-rev:
- 155901
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/linux/installer/vboxadd.sh
r98595 r98609 176 176 } 177 177 178 running_module() 179 { 180 lsmod | grep -q $1 181 } 182 178 183 # Get version string of currently running kernel module. 179 184 running_module_version() … … 199 204 200 205 [ "$expected" = "$(running_module_version "$mod")" ] || return 206 } 207 208 # A wrapper for check_running_module_version. 209 # Go through the list of Guest Additions' modules and 210 # verify if they are loaded and running version matches 211 # to current installation version. Skip vboxvideo since 212 # it is not loaded for old guests. 213 check_status_kernel() 214 { 215 for mod in vboxguest vboxsf; do 216 running_module "$mod" || fail "module $mod not loaded" 217 check_running_module_version "$mod" || fail "currently loaded module $mod version ($(running_module_version "$mod")) does not match to VirtualBox Guest Additions installation version ($VBOX_VERSION $VBOX_REVISION)" 218 done 219 } 220 221 # Checks if systemctl is present and functional (i.e., systemd is the init process). 222 use_systemd() 223 { 224 systemctl status >/dev/null 2>&1 225 } 226 227 ## Did we install a systemd service? 228 systemd_service_installed() 229 { 230 ## Name of service to test. 231 name="${1}" 232 233 test -f /lib/systemd/system/"${name}".service || 234 test -f /usr/lib/systemd/system/"${name}".service 235 } 236 237 ## Perform an action on a service 238 do_sysvinit_action() 239 { 240 ## Name of service to start. 241 name="${1}" 242 ## The action to perform, normally "start", "stop" or "status". 243 action="${2}" 244 245 if use_systemd -a systemd_service_installed "${name}"; then 246 systemctl -q ${action} "${name}" 247 elif test -x "/etc/rc.d/init.d/${name}"; then 248 "/etc/rc.d/init.d/${name}" "${action}" quiet 249 elif test -x "/etc/init.d/${name}"; then 250 "/etc/init.d/${name}" "${action}" quiet 251 fi 252 } 253 254 # Check whether user-land processes are running. 255 # Currently only check for VBoxService. 256 check_status_user() 257 { 258 do_sysvinit_action vboxadd-service status >/dev/null 2>&1 201 259 } 202 260 … … 645 703 } 646 704 647 648 705 # Returns "1" if module is signed and signature can be verified 649 706 # with public key provided in DEB_PUB_KEY. Or empty string otherwise. … … 889 946 } 890 947 891 # Checks if systemctl is present and functional (i.e., systemd is the init process).892 use_systemd()893 {894 systemctl status >/dev/null 2>&1895 }896 897 ## Did we install a systemd service?898 systemd_service_installed()899 {900 ## Name of service to test.901 name="${1}"902 903 test -f /lib/systemd/system/"${name}".service ||904 test -f /usr/lib/systemd/system/"${name}".service905 }906 907 ## Perform an action on a service908 do_sysvinit_action()909 {910 ## Name of service to start.911 name="${1}"912 ## The action to perform, normally "start", "stop" or "status".913 action="${2}"914 915 if use_systemd -a systemd_service_installed "${name}"; then916 systemctl -q ${action} "${name}"917 elif test -x "/etc/rc.d/init.d/${name}"; then918 "/etc/rc.d/init.d/${name}" "${action}" quiet919 elif test -x "/etc/init.d/${name}"; then920 "/etc/init.d/${name}" "${action}" quiet921 fi922 }923 924 948 # Check if process with this PID is running. 925 949 check_pid() … … 1047 1071 if [ $? -eq 0 ]; then 1048 1072 1049 # Check if we just loaded modules of correct version. Skip vboxvideo 1050 # since it's not loaded for very old guests. 1051 for mod in vboxguest vboxsf; do 1052 check_running_module_version "$mod" || fail "currently loaded module $mod version ($(running_module_version "$mod")) does not match to VirtualBox Guest Additions installation version ($VBOX_VERSION $VBOX_REVISION)" 1053 done 1073 # Check if we just loaded modules of correct version. 1074 check_status_kernel 1075 1076 # Check if user-land processes were restarted as well. 1077 check_status_user 1078 1054 1079 # Take reported version of running Guest Additions from running vboxguest module (as a paranoia check). 1055 1080 info "kernel modules and services $(running_module_version "vboxguest") reloaded" … … 1119 1144 dmnstatus 1120 1145 ;; 1146 status-kernel) 1147 check_status_kernel && info "Kernel modules are loaded" 1148 ;; 1149 status-user) 1150 check_status_user 1151 if [ $? -eq 0 ]; then 1152 info "User-land services are running" 1153 else 1154 fail "User-land services are not running" 1155 fi 1156 ;; 1121 1157 *) 1122 echo "Usage: $0 {start|stop|restart|reload|status|s etup|quicksetup|cleanup} [quiet]"1158 echo "Usage: $0 {start|stop|restart|reload|status|status-kernel|status-user|setup|quicksetup|cleanup} [quiet]" 1123 1159 exit 1 1124 1160 esac
Note:
See TracChangeset
for help on using the changeset viewer.