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
2cd74fd9
Commit
2cd74fd9
authored
8 years ago
by
ulisse
Browse files
Options
Downloads
Patches
Plain Diff
now vm id or name MUST be the first argument, flags may follow
parent
844bc061
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
vm-start
+49
-46
49 additions, 46 deletions
vm-start
with
49 additions
and
46 deletions
vm-start
+
49
−
46
View file @
2cd74fd9
...
...
@@ -13,34 +13,15 @@ SRC_DIR="$(dirname $(readlink -f $0))"
.
${
SRC_DIR
}
/settings/common
# read all parameters
# set an initial value for the flags
NO_INIT
=
""
NO_RUN
=
""
# read the options (command line options override settings file values)
OPTS
=
`
getopt
-o
fgir
--long
fullscreen,gui,no-init,no-run
-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
=
""
;
shift
;;
-r
|
--no-run
)
NO_RUN
=
"1"
;
shift
;;
-i
|
--no-init
)
NO_INIT
=
"1"
;
shift
;;
--
)
shift
;
break
;;
esac
done
[
"$#"
-eq
1
]
||
usage_vm-start
"Error: one parameter required (
$#
provided)."
VM_ID
=
$1
[
"$#"
-gt
0
]
||
usage_vm-start
"Error: one parameter required (
$#
provided)."
# include global settings
.
${
SRC_DIR
}
/settings/settings
# get VM ID or name
VM_ID
=
$1
shift
# VM_ID lookup in settings files by ID or NAME
if
[
!
-f
"
$SRC_DIR
/settings/
${
VM_ID
}
.settings"
]
;
then
result
=
`
get_vm_id_by_name
"
${
VM_ID
}
"
`
...
...
@@ -50,27 +31,29 @@ if [ ! -f "$SRC_DIR/settings/${VM_ID}.settings" ]; then
fi
fi
if
[
$DEBUG
-eq
1
]
;
then
echo
"vm_id =
$VM_ID
"
echo
"fullscreen =
$FULLSCREEN
"
echo
"no-init =
$NO_INIT
"
echo
"no-run =
$NO_RUN
"
exit
1
fi
# include VM settings
.
"
${
SRC_DIR
}
/settings/
${
VM_ID
}
.settings"
#
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.
"
#
read the options (command line options override settings file values)
OPTS
=
`
getopt
-o
fgir
--long
fullscreen,gui,no-init,no-run
-n
"
$0
"
--
"
$@
"
`
eval set
--
"
$OPTS
"
# create temporary folder
if
[
!
-d
$TMP_DIR
]
;
then
mkdir
$TMP_DIR
fi
# extract options and their arguments into variables
while
true
;
do
case
"
$1
"
in
-f
|
--fullscreen
)
FULLSCREEN
=
"1"
;
shift
;;
-g
|
--gui
)
FULLSCREEN
=
""
;
shift
;;
-r
|
--no-run
)
NO_RUN
=
"1"
;
shift
;;
-i
|
--no-init
)
NO_INIT
=
"1"
;
shift
;;
--
)
shift
;
break
;;
esac
done
# no-init?
if
[
"
${
NO_INIT
}
"
!=
"1"
]
;
then
vm_start_init
()
{
# create temporary folder
if
[
!
-d
$TMP_DIR
]
;
then
mkdir
$TMP_DIR
fi
# remove files older than 12 hours
#find ${TMP_DIR} -name "*" -type f -mmin +720 -delete
...
...
@@ -132,12 +115,9 @@ if [ "${NO_INIT}" != "1" ]; then
else
echo
"Differential disk: autoreset=on"
fi
fi
# start vm
}
# --no-run?
if
[
"
${
NO_RUN
}
"
!=
"1"
]
;
then
vm_start_run
()
{
# --fullscreen?
if
[
"
${
FULLSCREEN
}
"
!=
""
]
;
then
# VBoxManage has no option for fullscreen mode, use VBoxSDL (no menu available in fullscreen)
...
...
@@ -150,5 +130,28 @@ if [ "${NO_RUN}" != "1" ]; then
else
VBoxManage startvm
"
${
VM_NAME
}
"
fi
}
if
[
$DEBUG
-eq
1
]
;
then
echo
"vm_id =
$VM_ID
"
echo
"fullscreen =
$FULLSCREEN
"
echo
"no-init =
$NO_INIT
"
echo
"no-run =
$NO_RUN
"
exit
1
fi
# 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."
# --no-init?
if
[
"
${
NO_INIT
}
"
!=
"1"
]
;
then
vm_start_init
fi
# --no-run?
if
[
"
${
NO_RUN
}
"
!=
"1"
]
;
then
vm_start_run
fi
exit
0
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