-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathagentgo
executable file
·45 lines (37 loc) · 929 Bytes
/
agentgo
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
#!/bin/sh
# vim: fdm=marker
# note: link this to ~/opt/goagent/
# desc: goagent local files configuration automation.
local_dir="$HOME/opt/goagent/local"
server_dir="$HOME/opt/goagent/server/gae"
# read password
read -p "input goagent password: " psw
cd "$server_dir" # {{{1
# set password
sed -ri "/^__password__ =/s/''/'$psw'/" gae.py
cd "$local_dir" # {{{1
# set permissions
find -maxdepth 1 -type f -exec chmod 644 {} +
chmod 755 proxy.py
# use right version
sed -ri '1s/python.?$/python2/' proxy.py
# configure proxy.ini
awk -v psw=" $psw" \
'BEGIN { RS = ORS = "\r\n"; FS = OFS = " =" }
{ switch ($1) {
case "visible":
$2 = " 0"
break
case "appid":
$2 = " g0aegent|g2aegent|g3aegent"
break
case "password":
$2 = psw
break
}
print $0
}' \
proxy.ini > proxy.ini.new &&
mv --backup --suffix='.old' proxy.ini.new proxy.ini
# done {{{1
echo "done"