-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
278 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
VboxExtpackAutoinstall | ||
=================== | ||
Simple script for automatic installation of VirtualBox Extension Pack. | ||
This is useful if your Linux Distribution doesn't come with Extension Pack installed by default. | ||
|
||
# Usage | ||
Just run the script: | ||
```bash | ||
./run.sh | ||
``` | ||
It will automatically download correct extension pack version and handle the installation process. | ||
|
||
# VirtualBox / Extension Pack version upgrade | ||
If the extension pack stops working due to a version upgrade, just re-run the script: | ||
```bash | ||
./run.sh | ||
``` | ||
It will automatically remove old version and fetch the new one. |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/usr/bin/env bash | ||
# @K.Dziuba | ||
# Virtual Box Extension Pack Automatic (Re)Install Script - Config File | ||
|
||
|
||
# =========================== | ||
# General settings | ||
# =========================== | ||
|
||
# VirutalBox version (i.e. "6.1.30") | ||
VBOX_VERSION="`getVboxVersion`" | ||
|
||
# download source | ||
REPOSITORY="https://download.virtualbox.org/virtualbox" | ||
FILE_NAME="Oracle_VM_VirtualBox_Extension_Pack-$VBOX_VERSION.vbox-extpack" | ||
|
||
# save location (will be removed automaticaly) | ||
SAVE_LOCATION="/tmp/$FILE_NAME" | ||
|
||
# package name (will be use for removing the old Extension Pack version) | ||
INSTALL_NAME="Oracle VM VirtualBox Extension Pack" | ||
|
||
|
||
# =================================== | ||
# Auth settings | ||
# =================================== | ||
# enable root authentication types | ||
# ----------------------------------- | ||
|
||
# enable for sudo authentication (recommended for Terminal) | ||
authWithSudo='yes' | ||
|
||
# enable for polkit/pkexec authentication (GUI only) | ||
# authWithPkexec='yes' | ||
|
||
# enable for zensu authentication | ||
# authWithZensu='yes' | ||
|
||
# enable for gksu authentication | ||
# authWithGksu='yes' |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/usr/bin/env bash | ||
# @K.Dziuba | ||
# Virtual Box Extension Pack Automatic (Re)Install Script - The Runner | ||
|
||
# ============== | ||
# Paths config | ||
# ============== | ||
SCRIPT_ROOT=$( readlink -f $( dirname "${BASH_SOURCE[0]}" ) ) | ||
|
||
# ============== | ||
# Sources | ||
# ============== | ||
source src/VboxExtpackAutoinstall.sh | ||
source config.sh | ||
|
||
# ================== | ||
# Invoke the script | ||
# ================== | ||
autoSetAuthPrefix | ||
set -eu | ||
main |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#!/usr/bin/env bash | ||
# @K.Dziuba | ||
# Virtual Box Extension Pack Automatic (Re)Install Script - Message/Print functions | ||
|
||
# Define colors (ANSI) | ||
C_RED='\033[0;31m' | ||
C_GREEN='\033[0;32m' | ||
C_BLUE='\033[0;34m' | ||
C_YELLOW='\033[1;33m' | ||
C_PURPLE='\033[0;35m' | ||
C_CYAN='\033[0;36m' | ||
C_NC='\033[0m' # no-color | ||
|
||
# Print error message | ||
# $1, $2, ... - message text | ||
printError() { | ||
row=1 | ||
while (( "$#" )); do | ||
if [[ row -eq '1' ]]; then | ||
>&2 echo -e "${C_RED} [ERROR] $1${C_NC}" | ||
else | ||
>&2 echo -e "${C_RED} $1${C_NC}" | ||
fi | ||
shift | ||
((row++)) | ||
done | ||
} | ||
|
||
# Print warning message | ||
# $1, $2, ... - message text | ||
printWarning() { | ||
row=1 | ||
while (( "$#" )); do | ||
if [[ row -eq '1' ]]; then | ||
>&2 echo -e "${C_YELLOW} [WARNING] $1${C_NC}" | ||
else | ||
>&2 echo -e "${C_YELLOW} $1${C_NC}" | ||
fi | ||
shift | ||
((row++)) | ||
done | ||
} | ||
|
||
# Print success message | ||
# $1, $2, ... - message text | ||
printSuccess() { | ||
while (( "$#" )); do | ||
echo -e " ${C_GREEN}$1${C_NC}" | ||
shift | ||
done | ||
} | ||
|
||
# Print notice message | ||
# $1, $2, ... - message text | ||
printNotice() { | ||
while (( "$#" )); do | ||
echo -e " ${C_PURPLE}$1${C_NC}" | ||
shift | ||
done | ||
} | ||
|
||
# Print info message | ||
# $1, $2, ... - message text | ||
printInfo() { | ||
while (( "$#" )); do | ||
echo -e " ${C_CYAN}$1${C_NC}" | ||
shift | ||
done | ||
} | ||
|
||
# Print plain text message | ||
# $1, $2, ... - message text | ||
printText() { | ||
while (( "$#" )); do | ||
echo -e " $1" | ||
shift | ||
done | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/env bash | ||
# @K.Dziuba | ||
# Virtual Box Extension Pack Automatic (Re)Install Script - System/Auth functions | ||
|
||
# sets the $authPrefix, if given binary exists | ||
# $1 - binary file | ||
setAuthPrefix() { | ||
if which "$1" | read; then | ||
authPrefix="$1" | ||
else | ||
printWarning "$1 not found! Skipping..." | ||
fi | ||
} | ||
|
||
# uses setAuthPrefix() to auto-set the $authPrefix defined in the config | ||
autoSetAuthPrefix() { | ||
authPrefix='' | ||
|
||
# Sudo support | ||
if [[ $authWithSudo == 'yes' ]]; then | ||
setAuthPrefix sudo | ||
fi | ||
|
||
# Zensu support | ||
if [[ $authWithZensu == 'yes' ]]; then | ||
setAuthPrefix zensu | ||
fi | ||
|
||
# Gksu support | ||
if [[ $authWithGksu == 'yes' ]]; then | ||
setAuthPrefix gksu | ||
fi | ||
|
||
# Polkit/pkexec support | ||
if [[ $authWithPkexec == 'yes' ]]; then | ||
setAuthPrefix pkexec | ||
fi | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
#!/usr/bin/env bash | ||
# @K.Dziuba | ||
# Virtual Box Extension Pack Automatic (Re)Install Script | ||
|
||
source src/IO/Print.sh | ||
source src/System/Auth.sh | ||
|
||
# main function | ||
main() { | ||
init | ||
|
||
# version notice | ||
if [[ $VBOX_VERSION == '' ]]; then | ||
printError "Could not detect VirtualBox version!" \ | ||
"(VERSION = '$VBOX_VERSION')" | ||
failExit | ||
else | ||
printText "Detected VirtualBox version: $VBOX_VERSION" | ||
fi | ||
|
||
# download new version | ||
printNotice "" "Downloading the extpack ..." | ||
wget "$REPOSITORY/$VBOX_VERSION/$FILE_NAME" -O "$SAVE_LOCATION" \ | ||
&& confirmSuccess || failExit | ||
|
||
# remove old version | ||
printNotice "" "Removing old extpack version ..." | ||
$authPrefix vboxmanage extpack uninstall "$INSTALL_NAME" \ | ||
&& confirmSuccess || failExit | ||
|
||
# install new version | ||
printNotice "" "Installing new extpack version ..." | ||
$authPrefix vboxmanage extpack install "$SAVE_LOCATION" \ | ||
&& confirmSuccess || failExit | ||
|
||
# all done | ||
printSuccess "" "Installation is done!" | ||
terminate | ||
} | ||
|
||
# print standard success message | ||
confirmSuccess() { | ||
printSuccess "... OK!" | ||
} | ||
|
||
# fail and exit the script | ||
failExit() { | ||
FLAG_FAILED=1 | ||
printError "... Failed!" | ||
terminate | ||
} | ||
|
||
# returns the Virtual Box version | ||
getVboxVersion() { | ||
vboxmanage -v | cut -d'r' -f1 | ||
} | ||
|
||
# pre-run function | ||
init() { | ||
printInfo "[$0] Starting up ..." | ||
|
||
# traps | ||
trap terminate SIGINT SIGTERM ERR | ||
|
||
# init flags | ||
FLAG_FAILED=0 | ||
} | ||
|
||
# post-run / terminate function | ||
terminate() { | ||
printInfo "[$0] Terminating ..." | ||
|
||
# cleanup | ||
if [[ -f "$SAVE_LOCATION" ]]; then | ||
rm "$SAVE_LOCATION" | ||
fi | ||
|
||
if [[ FLAG_FAILED ]]; then | ||
exit 1 | ||
else | ||
exit 0 | ||
fi | ||
} |