-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall_generic_worker.sh
executable file
·143 lines (117 loc) · 4.65 KB
/
install_generic_worker.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#!/bin/bash
# Run as root
# GitHub repository information
REPO="taskcluster/taskcluster"
# Asset names to download
ASSETS=(
"generic-worker-multiuser-darwin-amd64"
"livelog-darwin-arm64"
"start-worker-darwin-arm64"
"taskcluster-proxy-darwin-arm64"
)
# Directory to place the binaries
TARGET_DIR="/usr/local/bin"
# Get the latest release information from the GitHub API
latest_release_info=$(curl -s https://api.github.com/repos/$REPO/releases/latest)
for asset in "${ASSETS[@]}"; do
# Extract the download URL for the asset
download_url=$(echo "$latest_release_info" | grep 'browser_download_url' | grep "$asset" | awk -F '"' '{print $4}')
# Check if the download URL was found
if [[ -z "$download_url" ]]; then
echo "Error: Could not find the $asset asset in the latest release."
continue
fi
# Determine the target filename by removing the -arm64 suffix
target_filename=$(echo "$asset" | sed 's/-darwin-arm64//;s/-amd64//')
# Download the asset to the target directory
curl -L -o "$TARGET_DIR/$target_filename" "$download_url"
# Make the binary executable
chmod +x "$TARGET_DIR/$target_filename"
echo "Downloaded and installed $target_filename to $TARGET_DIR successfully."
done
# Generate a key for signing artifacts. The private key will be written to the file
# /etc/generic-worker/ed25519_key, and the public key will be written to standard out.
# Keep a copy of the public key if you wish to validate artifact signatures.
mkdir /etc/generic-worker
/usr/local/bin/generic-worker new-ed25519-keypair --file /etc/generic-worker/ed25519_key
# Create the /usr/local/bin/run-generic-worker.sh script
cat << 'EOF' > /usr/local/bin/run-generic-worker.sh
#!/bin/bash
. /etc/rc.common
CheckForNetwork
while [ "${NETWORKUP}" != "-YES-" ]
do
sleep 5
NETWORKUP=
CheckForNetwork
done
cd ~
/usr/local/bin/start-worker /etc/generic-worker/runner.yml
EOF
# Make the run-generic-worker.sh script executable
chmod +x /usr/local/bin/run-generic-worker.sh
echo "Created and made /usr/local/bin/run-generic-worker.sh executable."
# Create /etc/generic-worker/runner.yml with the specified configuration
cat << 'EOF' > /etc/generic-worker/runner.yml
getSecrets: false
provider:
clientID: project/releng/generic-worker/datacenter-gecko-t-osx-1400-m2-staging
providerType: standalone
rootURL: "https://firefox-ci-tc.services.mozilla.com"
providerID: standalone
accessToken: "********************************************"
workerPoolID: releng-hardware/gecko-t-osx-1400-m2-staging
workerGroup: macstadium-vegas
workerID: moz-runner-multi-1
workerLocation:
host: macstadium
worker:
implementation: generic-worker
path: /usr/local/bin/generic-worker
configPath: /etc/generic-worker/config
workerConfig:
cachesDir: "/Library/Caches/generic-worker/caches"
cleanUpTaskDirs: true
disableReboots: false
downloadsDir: "/Library/Caches/generic-worker/downloads"
ed25519SigningKeyLocation: "/etc/generic-worker/ed25519_key"
livelogExecutable: "/usr/local/bin/livelog"
publicIP: "192.168.5.174"
requiredDiskSpaceMegabytes: 20480
runTasksAsCurrentUser: true
sentryProject: "generic-worker"
shutdownMachineOnIdle: false
shutdownMachineOnInternalError: false
taskclusterProxyExecutable: "/usr/local/bin/taskcluster-proxy"
taskclusterProxyPort: 8080
tasksDir: "/Users"
wstAudience: "firefoxcitc"
wstServerURL: "https://firefoxci-websocktunnel.services.mozilla.com/"
EOF
echo "Created /etc/generic-worker/runner.yml with the specified configuration."
# Create the /Library/LaunchDaemons/com.mozilla.genericworker.plist file
cat << 'EOF' > /Library/LaunchDaemons/com.mozilla.genericworker.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.mozilla.genericworker</string>
<key>Program</key>
<string>/usr/local/bin/run-generic-worker.sh</string>
<key>StandardOutPath</key>
<string>/var/log/genericworker/stdout.log</string>
<key>StandardErrorPath</key>
<string>/var/log/genericworker/stderr.log</string>
<key>RunAtLoad</key>
<true/>
<key>UserName</key>
<string>root</string> <!-- (for multiuser build) -->
<string>genericworker</string> <!-- (for insecure build) -->
</dict>
</plist>
EOF
echo "Created /Library/LaunchDaemons/com.mozilla.genericworker.plist with the specified configuration."
# Load the LaunchDaemon to start the generic worker at boot
# sudo launchctl load -w /Library/LaunchDaemons/com.mozilla.genericworker.plist
# echo "Loaded the LaunchDaemon to start the generic worker at boot."