Last active
March 11, 2018 22:42
-
-
Save shadowbq/5897002b620b093ca7578b5f13c3f3a1 to your computer and use it in GitHub Desktop.
AskUbuntu SO #966585 - Post Kernel Upgrade
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Must be run as root / sudo | |
# Reference: https://askubuntu.com/questions/966585/ubuntu-17-10-upgrade-broke-vmware-workstation-12-5 | |
if [ $(dpkg-query -W -f='${Status}' linux-headers-generic 2>/dev/null | grep -c "ok installed") -eq 0 ]; | |
then | |
echo "Kernel Headers Package Missing" | |
echo "apt-get install linux-headers-generic"; | |
exit 1 | |
fi | |
if [ ! -d "/usr/lib/vmware/modules/source/vmmon-only/" ] | |
then | |
echo "Failed to find expanded source vmmon" | |
exit 1 | |
if [ ! -d "/usr/lib/vmware/modules/source/vmnet-only/" ] | |
then | |
echo "Failed to find expanded source vmnet" | |
exit 1 | |
fi | |
fi | |
current_kernel=$(uname -r) | |
kern_dir=$(find /lib/modules/ -maxdepth 1 -type d|sort -n|tail -1) | |
latest_kern=${kern_dir##*/} | |
if [ $latest_kern == $current_kernel ] | |
then | |
echo "Running current kernel: $current_kernel " | |
else | |
echo "Current Running kernel, and latest downloaded kernel do not match." | |
echo "Running kernel: $current_kernel " | |
echo "Latest kernel downloaded: $latest_kern " | |
echo "Reboot likely required!..exiting" | |
exit 1 | |
fi | |
if [ ! -f "$kern_dir/misc/vmmon.ko" ] | |
then | |
echo "Building New kernels modules" | |
mkdir -p $kern_dir/misc/ | |
cd /usr/lib/vmware/modules/source/vmmon-only/ | |
make clean | |
make | |
cp ./vmmon.ko $kern_dir/misc/ | |
cd /usr/lib/vmware/modules/source/vmnet-only/ | |
make clean | |
make | |
cp ./vmnet.ko $kern_dir/misc/ | |
else | |
echo "Found Kernel Modules" | |
modinfo $kern_dir/misc/vmmon.ko | |
modinfo $kern_dir/misc/vmnet.ko | |
fi | |
kernel_count=$(lsmod|grep 'vm[mon|net]'|wc -l) | |
if [[ $kernel_count -lt 2 ]]; | |
then | |
echo "Reloading Kernel Modules" | |
rmmod -v vmmon.ko 2>/dev/null | |
insmod $kern_dir/misc/vmmon.ko | |
rmmod -v vmnet.ko 2>/dev/null | |
insmod $kern_dir/misc/vmnet.ko | |
lsmod |grep 'vm[mon|net]' | |
else | |
echo "Kernel Modules Loaded Already" | |
fi | |
vmnetwork_status=$(vmware-networks --status 2>/dev/null |grep 'is not running' |wc -l) | |
if [[ $vmnetwork_status -gt 0 ]]; | |
then | |
echo "Starting VMware Networks" | |
vmware-networks --start | |
fi | |
if ! vmware-networks --status; then | |
echo "Error handling vmware-networks..exiting" | |
exit 1; | |
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
echo "Launching VMWare Workstation Wrapper" | |
echo "Starting VMkernel Prep" | |
if sudo /opt/vmware-kernel-hack/vmkernel_prep.sh; then | |
echo "Starting VMware Workstation" | |
/usr/lib/vmware/bin/vmware | |
else | |
echo "Error in vmware kernel prep" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Running when only needing to do a check