Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
vbox-scripts
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alberto LIVIO BECCARIA
vbox-scripts
Commits
c2d0b447
Commit
c2d0b447
authored
6 years ago
by
Alberto LIVIO BECCARIA
Browse files
Options
Downloads
Patches
Plain Diff
Code restyling and improved argument parsing in vm-start.
parent
0ea53ba1
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
vm-setup
+1
-1
1 addition, 1 deletion
vm-setup
vm-start
+73
-38
73 additions, 38 deletions
vm-start
with
74 additions
and
39 deletions
vm-setup
+
1
−
1
View file @
c2d0b447
#!/bin/bash
#############################################
# VirtualBox VM Scripts
18.5.4
- vm-setup
# VirtualBox VM Scripts - vm-setup
# by ulisse aka A. Livio Beccaria
#
# vm-setup sets a VM up
...
...
This diff is collapsed.
Click to expand it.
vm-start
+
73
−
38
View file @
c2d0b447
#!/bin/bash
#############################################
# VirtualBox VM Scripts
18.5.4
- vm-start
# VirtualBox VM Scripts - vm-start
# by ulisse aka A. Livio Beccaria
#
# vm-start starts a VM :)
#############################################
APP_NAME
=
"vm-start - VirtualBox VM Scripts"
VERSION
=
"18.5.
4
"
VERSION
=
"18.5.
7
"
AUTHOR
=
"DiSIT"
# source folder
...
...
@@ -157,14 +157,14 @@ vm_discard_state() {
##############
vm_start_run
()
{
# --fullscreen?
if
[
"
${
FULLSCREEN
}
"
==
"1"
]
;
then
if
[
[
${
FULLSCREEN
}
==
1
]
]
;
then
# VBoxManage has no option for fullscreen mode, use VBoxSDL (no menu available in fullscreen)
# VBoxSDL --startvm "${VM_NAME}" --fullscreen
&
# VBoxSDL --startvm "${VM_NAME}" --fullscreen
# options below could be useful in setting the fullscreen resolution, when known
# --fullscreenresize --fixedmode 1152 864 32
&
# --fullscreenresize --fixedmode 1152 864 32
#
# the following command can also be used to start the VM in fullscreen (GUI mode)
/usr/bin/VirtualBox
--startvm
"
${
VM_NAME
}
"
--fullscreen
&
/usr/bin/VirtualBox
--startvm
"
${
VM_NAME
}
"
--fullscreen
else
VBoxManage startvm
"
${
VM_NAME
}
"
fi
...
...
@@ -172,44 +172,70 @@ vm_start_run() {
###############################################################################
# print title
title
###############################################################################
# Parse arguments
#################
[
"$#"
-gt
0
]
||
usage
"ERROR: one argument required (
$#
provided)."
# get VM ID or name
VM_ID
=
$1
shift
# read the options (command line options override settings file values)
OPTS
=
`
getopt
-o
fgirsd
--long
fullscreen,gui,no-init,no-run,discard-state,debug
-n
"
$0
"
--
"
$@
"
`
eval set
--
"
$OPTS
"
# extract options and their arguments into variables
while
true
;
do
case
"
$1
"
in
-f
|
--fullscreen
)
FULLSCREEN
=
"1"
;
shift
;;
-g
|
--gui
)
FULLSCREEN
=
"0"
;
shift
;;
-r
|
--no-run
)
NO_RUN
=
"1"
;
shift
;;
-i
|
--no-init
)
NO_INIT
=
"1"
;
shift
;;
-s
|
--discard-state
)
DISCARD_STATE
=
"1"
;
shift
;;
-d
|
--debug
)
DEBUG
=
"1"
;
shift
;;
--
)
shift
;
break
;;
[[
"$#"
-ge
1
]]
||
usage
"ERROR: one argument required (
$#
provided)."
VM_ID
=
""
DEBUG
=
0
FULLSCREEN_CL
=
-1
FULLSCREEN
=
0
NO_RUN
=
0
NO_INIT
=
0
DISCARD_STATE
=
0
while
[
"
$1
"
!=
""
]
;
do
PARAM
=
`
echo
$1
|
awk
-F
=
'{print $1}'
`
VALUE
=
`
echo
$1
|
awk
-F
=
'{print $2}'
`
case
${
PARAM
}
in
-h
|
--help
)
usage
""
exit
0
;;
-g
|
--gui
)
FULLSCREEN_CL
=
0
shift
;;
-f
|
--fullscreen
)
FULLSCREEN_CL
=
1
shift
;;
-i
|
--no-init
)
NO_INIT
=
1
shift
;;
-r
|
--no-run
)
NO_RUN
=
1
shift
;;
-s
|
--discard-state
)
DISCARD_STATE
=
1
shift
;;
-d
|
--debug
)
DEBUG
=
1
shift
;;
*
)
if
[[
"
${
VM_ID
}
"
==
""
]]
;
then
VM_ID
=
${
PARAM
}
shift
else
usage
"ERROR: unknown argument
\"
${
PARAM
}
\"
."
exit
1
fi
;;
esac
done
###############################################################################
# print title
title
# print debug info if needed
debug
# include global settings
.
"
${
SRC_DIR
}
/settings/settings"
...
...
@@ -218,7 +244,7 @@ if [ ! -f "$SRC_DIR/settings/${VM_ID}.settings" ]; then
result
=
`
get_vm_id_by_name
"
${
VM_ID
}
"
`
VM_ID
=
$result
if
[
!
-f
"
$SRC_DIR
/settings/
${
VM_ID
}
.settings"
]
;
then
usage
"ERROR: wrong vm
id or name."
usage
"ERROR: wrong vm
_
id or name."
fi
fi
...
...
@@ -226,6 +252,15 @@ fi
.
"
${
SRC_DIR
}
/settings/
${
VM_ID
}
.settings"
# override VM fullscreen setting if set on command line
if
[[
${
FULLSCREEN_CL
}
!=
-1
]]
;
then
FULLSCREEN
=
${
FULLSCREEN_CL
}
fi
# print debug info if needed
debug
# check if VM exists
VBoxManage showvminfo
"
${
VM_NAME
}
"
&> /dev/null
[
"
$?
"
-eq
0
]
||
die
"ERROR: VM not configured. Run 'vm-setup
${
VM_ID
}
' and try again."
...
...
@@ -242,17 +277,17 @@ if [ "$current_snapshot_folder" != "${USER_TMP_DIR}" ]; then
fi
# --no-init?
if
[
"
${
NO_INIT
}
"
!=
"1"
]
;
then
if
[
[
${
NO_INIT
}
==
0
]
]
;
then
vm_start_init
fi
# --discard-state?
if
[
"
${
DISCARD_STATE
}
"
==
"1"
]
;
then
if
[
[
${
DISCARD_STATE
}
==
1
]
]
;
then
vm_discard_state
fi
# --no-run?
if
[
"
${
NO_RUN
}
"
!=
"1"
]
;
then
if
[
[
${
NO_RUN
}
==
0
]
]
;
then
vm_start_run
fi
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment