Demarrage vm auto
tom45
-
zipe31 Messages postés 38797 Statut Contributeur -
zipe31 Messages postés 38797 Statut Contributeur -
bonjour j'essaie de suivre cette procédure pour démarrer automatiquement ma vm qui tourne avec virtualbox sur un centos 7 mais j'ai une erreur
http://techrefjp.blogspot.com/2013/02/virtualbox-automatique-centos-fedora.html?_sm_au_=iVVD996Z6j6q5ZKN
à la commande service vboxcontrol start
il me dit echoué /etc/init.d/vboxcontrol : line 2: l : command not found
avez vous une idée ou peut étre ce n'est pas le bon tuto
http://techrefjp.blogspot.com/2013/02/virtualbox-automatique-centos-fedora.html?_sm_au_=iVVD996Z6j6q5ZKN
à la commande service vboxcontrol start
il me dit echoué /etc/init.d/vboxcontrol : line 2: l : command not found
avez vous une idée ou peut étre ce n'est pas le bon tuto
A voir également:
- Virtualbox autostart
- Forcer demarrage pc - Guide
- Ordinateur lent au démarrage - Guide
- Reinitialiser pc au demarrage - Guide
- Problème démarrage windows 10 - Guide
- Demarrage windows 10 - Guide
1
2 l Startup script for VirtualBox Virtual Machines
3 #
4 # chkconfig: 345 98 02
5 # description: Manages VirtualBox VMs
6 # processname: vboxcontrol
7 #
8 # pidfile: /var/run/vboxcontrol/vboxcontrol.pid
9 #
10 ### BEGIN INIT INFO
11 #
12 ### END INIT INFO
13 #
14 # Version 20090301 by Kevin Swanson <kswan.info> based on:
15 # Version 2008051100 by Jochem Kossen <***@***>
16 # http://farfewertoes.com
17 #
18 # Released in the public domain
19 #
20 # This file came with a README file containing the instructions on how
21 # to use this script.
22 #
23
24 # Source function library.
25 if [ -f /etc/init.d/functions ] ; then
26 . /etc/init.d/functions
27 elif [ -f /etc/rc.d/init.d/functions ] ; then
28 . /etc/rc.d/init.d/functions
29 else
30 exit 1
31 fi
32
33 ################################################################################
34 # INITIAL CONFIGURATION
35 VBOXDIR="/etc/virtualbox"
36 VM_USER="root"
37 USE_NAT="no"
38
39 export PATH="${PATH:+$PATH:}/bin:/usr/bin:/usr/sbin:/sbin"
40
41 if [ -f $VBOXDIR/config ]; then
42 . $VBOXDIR/config
43 fi
44
45 SU="su $VM_USER -c"
46 VBOXMANAGE="VBoxManage -nologo"
47
48 ################################################################################
49 # FUNCTIONS
50
51 # Determine if USE_NAT is set to "yes"
52 use_nat() {
53 if [ "$USE_NAT" = "yes" ]; then
54 return `true`
55 else
56 return `false`
57 fi
58 }
59
60 log_failure_msg() {
61 echo $1
62 }
63
64 log_action_msg() {
65 echo $1
66 }
67
68 # Check for running machines every few seconds; return when all machines are
69 # down
70 wait_for_closing_machines() {
71 RUNNING_MACHINES=`$SU "$VBOXMANAGE list runningvms" | wc -l`
72 if [ $RUNNING_MACHINES != 0 ]; then
73 sleep 5
74 wait_for_closing_machines
75 fi
76 }
77
78 ################################################################################
79 # RUN
80 case "$1" in
81 start)
82 if [ -f /etc/virtualbox/machines_enabled ]; then
83
84 cat /etc/virtualbox/machines_enabled | while read VM; do
85 log_action_msg "Starting VM: $VM ..."
86 $SU "$VBOXMANAGE startvm "$VM" -type vrdp"
87 RETVAL=$?
88 done
89 touch /var/lock/subsys/vboxcontrol
90 fi
91 ;;
92 stop)
93 # NOTE: this stops all running VM's. Not just the ones listed in the
94 # config
95 $SU "$VBOXMANAGE list runningvms" | while read VM; do
96 log_action_msg "Shutting down VM: $VM ..."
97 $SU "$VBOXMANAGE controlvm "$VM" acpipowerbutton"
98 done
99 rm -f /var/lock/subsys/vboxcontrol
100 wait_for_closing_machines
101
102 ;;
103 start-vm)
104 log_action_msg "Starting VM: $2 ..."
105 $SU "$VBOXMANAGE startvm "$2" -type vrdp"
106 ;;
107 stop-vm)
108 log_action_msg "Stopping VM: $2 ..."
109 $SU "$VBOXMANAGE controlvm "$2" acpipowerbutton"
110 ;;
111 poweroff-vm)
112 log_action_msg "Powering off VM: $2 ..."
113 $SU "$VBOXMANAGE controlvm "$2" poweroff"
114 ;;
115 status)
116 echo "The following virtual machines are currently running:"
117 $SU "$VBOXMANAGE list runningvms" | while read VM; do
118 echo -n "$VM ("
119 echo -n `$SU "VBoxManage showvminfo ${VM%% *}|grep Name:|sed -e 's/^Name:s*//g'"`
120 echo ')'
121 done
122 ;;
123 *)
124 echo "Usage: $0 {start|stop|status|start-vm <VM
125 name>|stop-vm <VM name>|poweroff-vm <VM name>}"
126 exit 3
127 esac
128
129 exit 0
Regarde le bon fichier sur le lien que tu as donné, et rectifie ce qui ne va pas.
#! /bin/sh
# vboxcontrol et ya le | en trop
question con mais je ne suis pas habituer à linux les #c'est des commentaires?
Alors oui, le croisillon c'est pour commenter, mais en ce qui concerne la 1ère ligne commençant par "!#" c'est une autre histoire. Ça s'appelle un shebang et ça sert à introduire le programme qui sera appelé pour interpréter les lignes de codes qui suivent.
Cette ligne est quasiment indispensable.
pour info j'ai modifier le script j'ai une erreur starting vboxcontrol job for vboxcontrol.service failed because the control process exited with error code