source: orange/install-scripts/vmware/vmware-dailyrun-macosx-6-fink64bit.sh @ 8099:4e25818916f6

Revision 8099:4e25818916f6, 3.1 KB checked in by mitar, 3 years ago (diff)

Always use just already prepared source (created in 10.5 run).

  • Property exe set to *
Line 
1#!/bin/bash
2#
3# Should be run as: ./vmware-dailyrun-macosx-6-fink64bit.sh
4#
5
6VMRUN='/Library/Application Support/VMware Fusion/vmrun'
7VMIMAGE='/Volumes/Data/vmware/Mac OS X Server 10.6 64-bit (64-bit Fink).vmwarevm/Mac OS X Server 10.6 64-bit.vmx'
8WAIT_START_TIME=300
9WAIT_STOP_TIME=600
10WAIT_RESTART_TIME=120
11RETRIES=5
12IP_ADDRESS='172.16.213.104'
13NAME='Mac OS X 10.6 (64-bit Fink)'
14
15# We use public/private keys SSH authentication so no need for a password
16
17start_vmware() {
18    if "$VMRUN" list | grep -q "$VMIMAGE"; then
19        echo "[$NAME] VMware is already running."
20        exit 1
21    fi
22   
23    # We hide some Mac OS X warnings which happen if nobody is logged into a host Mac OS X
24    "$VMRUN" start "$VMIMAGE" nogui 2>&1 | grep -i -v 'Untrusted apps are not allowed to connect to or launch Window Server before login' | grep -i -v 'FAILED TO establish the default connection to the WindowServer' | grep -i -v 'kCGErrorFailure'
25    ps=("${PIPESTATUS[@]}")
26    # PIPESTATUS check is needed so that we test return value of the VMRUN and not grep
27    if ((${ps[0]})); then
28        echo "[$NAME] Could not start VMware."
29        exit 2
30    fi
31   
32    # Wait for VMware and OS to start
33    sleep $WAIT_START_TIME
34   
35    return 0
36}
37
38stop_vmware() {
39    # shutdown is added to /etc/sudoers so no password is required
40    # /etc/sudoers entry: ailabc ALL=NOPASSWD:/sbin/shutdown -h now
41    ssh ailabc@$IP_ADDRESS "sudo /sbin/shutdown -h now > /dev/null"
42   
43    # Wait for OS to stop
44    sleep $WAIT_STOP_TIME
45   
46    if "$VMRUN" list | grep -q "$VMIMAGE"; then
47        echo "[$NAME] Have to force shutdown."
48        # We hide some Mac OS X warnings which happen if nobody is logged into a host Mac OS X
49        "$VMRUN" stop "$VMIMAGE" nogui 2>&1 | grep -i -v 'Untrusted apps are not allowed to connect to or launch Window Server before login' | grep -i -v 'FAILED TO establish the default connection to the WindowServer' | grep -i -v 'kCGErrorFailure' | true
50        ps=("${PIPESTATUS[@]}")
51        # PIPESTATUS check is needed so that we test return value of the VMRUN and not grep
52        if ((${ps[0]})); then
53            echo "[$NAME] Could not stop VMware."
54            exit 3
55        fi
56    fi
57   
58    return 0
59}
60
61start_vmware
62
63# Check if autologin was successful
64for LOGGED_IN in {1..$RETRIES}; do
65    if ssh ailabc@$IP_ADDRESS "who | grep -q console"; then
66        # Autologin was successful
67        break
68    fi
69   
70    stop_vmware
71   
72    # Wait for VMware to stop
73    sleep $WAIT_RESTART_TIME
74   
75    start_vmware
76done
77
78if ! ssh ailabc@$IP_ADDRESS "who | grep -q console"; then
79    # Autologin was not successful after few retries, give up
80    echo "[$NAME] Could not autologin."
81    stop_vmware
82    exit 4
83fi
84
85# We run it twice so that we also use maybe updated "update-all-scripts.sh" script
86ssh ailabc@$IP_ADDRESS "/Users/ailabc/update-all-scripts.sh"
87ssh ailabc@$IP_ADDRESS "/Users/ailabc/update-all-scripts.sh"
88
89# dailyrun-finkonly.sh is added to /etc/sudoers so no password is required
90# /etc/sudoers entry: ailabc ALL=NOPASSWD:/Users/ailabc/dailyrun-finkonly.sh
91# WARNING: This is generally insecure as an attacker could change dailyrun-finkonly.sh file and ...
92#          but we are using it in a VMware which is used only for this script, so ...
93ssh ailabc@$IP_ADDRESS "sudo /Users/ailabc/dailyrun-finkonly.sh"
94
95stop_vmware
Note: See TracBrowser for help on using the repository browser.