Commit 0e2c169 1 parent eda2839 commit 0e2c169 Copy full SHA for 0e2c169
File tree 2 files changed +36
-7
lines changed
2 files changed +36
-7
lines changed Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ while true; do
53
53
ELAPSED_TIME=$(( ELAPSED_TIME + WAIT_TIME))
54
54
done
55
55
56
- SSH_SCRIPT=" sed -i ' s/^#\?Port [0-9]\+/Port ${ssh_port} /' /etc/ssh/sshd_config && systemctl restart sshd"
56
+ SSH_SCRIPT=' sed -i \" s/^#\\ ?Port [0-9]\\ +/Port ' ${ssh_port} ' /\" /etc/ssh/sshd_config && systemctl restart sshd'
57
57
58
58
ELAPSED_TIME=0
59
59
SSH_SUCEED_TIMES=0
81
81
82
82
# change the password
83
83
if [ -n " $password " ]; then
84
- virsh set-user-password --domain inst-$vm_ID --user root --password $password
85
- [ $? -ne 0 ] && die " Failed to set user password"
86
- echo " |:-COMMAND-:| $( basename $0 ) '$1 ' 'success'"
84
+ log_debug $vm_ID " $vm_ID setting user password"
85
+ output=$( virsh set-user-password --domain $vm_ID --user root --password $password 2>&1 )
86
+ exit_code=$?
87
+ if [ $exit_code -ne 0 ]; then
88
+ log_debug $vm_ID " Failed to set user password: $output "
89
+ die " Failed to set user password: $output "
90
+ fi
91
+ log_debug $vm_ID " $vm_ID set user password succeed"
87
92
fi
Original file line number Diff line number Diff line change 81
81
82
82
# change the password
83
83
if [ -n " $password " ]; then
84
- virsh set-user-password --domain inst-$vm_ID --user Administrator --password $password
85
- [ $? -ne 0 ] && die " Failed to set user password"
86
- echo " |:-COMMAND-:| $( basename $0 ) '$1 ' 'success'"
84
+ log_debug $vm_ID " $vm_ID setting user password"
85
+ output=$( virsh set-user-password --domain $vm_ID --user Administrator --password $password 2>&1 )
86
+ exit_code=$?
87
+ if [ $exit_code -ne 0 ]; then
88
+ log_debug $vm_ID " Failed to set user password: $output "
89
+ die " Failed to set user password: $output "
90
+ fi
91
+ log_debug $vm_ID " $vm_ID set user password succeed"
92
+
93
+ log_debug $vm_ID " Forcing group policy update..."
94
+ virsh qemu-agent-command $vm_ID ' {
95
+ "execute":"guest-exec",
96
+ "arguments": {
97
+ "path": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
98
+ "arg": ["/c","gpupdate /force"]
99
+ }
100
+ }' & > /dev/null
101
+
102
+ log_debug $vm_ID " Logging off current user..."
103
+ virsh qemu-agent-command $vm_ID ' {
104
+ "execute": "guest-exec",
105
+ "arguments": {
106
+ "path": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
107
+ "arg": ["-Command", "logoff"],
108
+ "capture-output": true
109
+ }
110
+ }'
87
111
fi
You can’t perform that action at this time.
0 commit comments