-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·201 lines (184 loc) · 6.92 KB
/
setup.sh
File metadata and controls
executable file
·201 lines (184 loc) · 6.92 KB
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
#!/bin/bash
# ============================================================================
# Recruitment Tool - Setup (Mac / Linux)
# ============================================================================
set -e
echo ""
echo "============================================="
echo " Recruitment Tool - Setup"
echo "============================================="
echo ""
# ---- Step 1: Check for Node.js ----
echo "Step 1: Checking for Node.js..."
if ! command -v node &> /dev/null; then
echo ""
echo " Node.js is not installed. Attempting to install automatically..."
if command -v brew &> /dev/null; then
echo " Detected Homebrew. Installing Node.js..."
brew install node
elif command -v apt-get &> /dev/null; then
echo " Detected APT. Installing Node.js (this may require sudo password)..."
sudo apt-get update && sudo apt-get install -y nodejs npm
elif command -v dnf &> /dev/null; then
echo " Detected DNF. Installing Node.js (this may require sudo password)..."
sudo dnf install -y nodejs
elif command -v yum &> /dev/null; then
echo " Detected YUM. Installing Node.js (this may require sudo password)..."
sudo yum install -y nodejs
else
echo " ERROR: Could not detect a supported package manager (brew, apt, dnf, yum)."
echo " Please download and install Node.js manually from: https://nodejs.org"
echo ""
exit 1
fi
if ! command -v node &> /dev/null; then
echo " ERROR: Node.js installation failed or isn't in your PATH."
echo " Please download and install it manually from: https://nodejs.org"
echo ""
exit 1
fi
fi
NODE_VERSION=$(node -v)
echo " OK - Node.js ${NODE_VERSION} found"
echo ""
# ---- Step 2: Install npm dependencies ----
echo "Step 2: Installing dependencies..."
npm install
echo ""
echo " OK - Dependencies installed"
echo ""
# ---- Step 3: Install Playwright Chromium ----
echo "Step 3: Installing Chromium browser (this may take a minute)..."
npx playwright install chromium
echo ""
echo " OK - Chromium installed"
echo ""
# ---- Step 4: Google Apps Script instructions ----
echo "============================================="
echo " Step 4: Google Apps Script Setup"
echo "============================================="
echo ""
echo " Follow these steps to connect your Google Sheet:"
echo ""
echo " 1. Open Google Sheets and create a new spreadsheet"
echo " 2. Go to Extensions > Apps Script"
echo " 3. Delete any existing code in the editor"
echo " 4. Open the file 'google_apps_script.js' from this folder"
echo " in any text editor (e.g. Notepad, TextEdit)"
echo " 5. Select All (Ctrl+A / Cmd+A) and Copy (Ctrl+C / Cmd+C)"
echo " 6. Paste it into the Apps Script editor (Ctrl+V / Cmd+V)"
echo " 7. Click the Save icon (or Ctrl+S / Cmd+S)"
echo " 8. Click Deploy > New deployment"
echo " 9. Click the gear icon next to 'Select type' > choose 'Web app'"
echo " 10. Set 'Who has access' to 'Anyone'"
echo " 11. Click 'Deploy'"
echo " 12. Click 'Authorize access' and follow the prompts"
echo " 13. Copy the Web App URL that appears"
echo ""
echo "============================================="
echo ""
# ---- Step 5: Get Web App URL from user ----
read -rp " Paste your Web App URL here: " WEBAPP_URL
# Basic validation
if [[ ! "$WEBAPP_URL" =~ ^https://script\.google\.com/macros/ ]]; then
echo ""
echo " That doesn't look like a Google Apps Script Web App URL."
echo " Expected format: https://script.google.com/macros/s/.../exec"
echo ""
read -rp " Try again - paste your Web App URL here: " WEBAPP_URL
fi
# ---- Step 6: Get Search Location ----
echo ""
while true; do
read -rp " Which State are you searching? (e.g. North Carolina or NC): " TARGET_STATE
# Pure bash validation
ABBR=""
case "$(echo "$TARGET_STATE" | tr '[:upper:]' '[:lower:]')" in
al|alabama) ABBR="AL" ;;
ak|alaska) ABBR="AK" ;;
az|arizona) ABBR="AZ" ;;
ar|arkansas) ABBR="AR" ;;
ca|california) ABBR="CA" ;;
co|colorado) ABBR="CO" ;;
ct|connecticut) ABBR="CT" ;;
de|delaware) ABBR="DE" ;;
fl|florida) ABBR="FL" ;;
ga|georgia) ABBR="GA" ;;
hi|hawaii) ABBR="HI" ;;
id|idaho) ABBR="ID" ;;
il|illinois) ABBR="IL" ;;
in|indiana) ABBR="IN" ;;
ia|iowa) ABBR="IA" ;;
ks|kansas) ABBR="KS" ;;
ky|kentucky) ABBR="KY" ;;
la|louisiana) ABBR="LA" ;;
me|maine) ABBR="ME" ;;
md|maryland) ABBR="MD" ;;
ma|massachusetts) ABBR="MA" ;;
mi|michigan) ABBR="MI" ;;
mn|minnesota) ABBR="MN" ;;
ms|mississippi) ABBR="MS" ;;
mo|missouri) ABBR="MO" ;;
mt|montana) ABBR="MT" ;;
ne|nebraska) ABBR="NE" ;;
nv|nevada) ABBR="NV" ;;
nh|"new hampshire") ABBR="NH" ;;
nj|"new jersey") ABBR="NJ" ;;
nm|"new mexico") ABBR="NM" ;;
ny|"new york") ABBR="NY" ;;
nc|"north carolina") ABBR="NC" ;;
nd|"north dakota") ABBR="ND" ;;
oh|ohio) ABBR="OH" ;;
ok|oklahoma) ABBR="OK" ;;
or|oregon) ABBR="OR" ;;
pa|pennsylvania) ABBR="PA" ;;
ri|"rhode island") ABBR="RI" ;;
sc|"south carolina") ABBR="SC" ;;
sd|"south dakota") ABBR="SD" ;;
tn|tennessee) ABBR="TN" ;;
tx|texas) ABBR="TX" ;;
ut|utah) ABBR="UT" ;;
vt|vermont) ABBR="VT" ;;
va|virginia) ABBR="VA" ;;
wa|washington) ABBR="WA" ;;
wv|"west virginia") ABBR="WV" ;;
wi|wisconsin) ABBR="WI" ;;
wy|wyoming) ABBR="WY" ;;
esac
if [ -n "$ABBR" ]; then
echo " OK - Targeting $ABBR"
break
else
echo " ERROR: '$TARGET_STATE' is not a recognized U.S. State."
echo " Please enter a full name (e.g. Georgia) or abbreviation (e.g. GA)."
fi
done
# ---- Step 7: Get MAI preference ----
echo ""
while true; do
read -rp " Do you want to include MAI designations in your search? (y/n): " INCLUDE_MAI
case "$INCLUDE_MAI" in
[yY]*) MAI_VAL="true"; break;;
[nN]*) MAI_VAL="false"; break;;
*) echo " ERROR: Please enter 'y' or 'n'.";;
esac
done
# ---- Step 8: Save config.json ----
node -e "require('fs').writeFileSync('config.json', JSON.stringify({ webAppUrl: process.argv[1], targetState: process.argv[2], includeMAI: process.argv[3] === 'true' }, null, 2) + '\n')" "$WEBAPP_URL" "$ABBR" "$MAI_VAL"
echo ""
echo " OK - Configuration saved to config.json"
echo ""
# ---- Step 7: Start the poller ----
echo "============================================="
echo " Setup complete!"
echo "============================================="
echo ""
echo " Go back to your Google Sheet, RELOAD the page,"
echo " then use the Recruitment Tool menu to run a scrape."
echo ""
echo " Keep this window open while you want the"
echo " scraper to be available."
echo ""
echo "============================================="
echo ""
node poller.js