-
Notifications
You must be signed in to change notification settings - Fork 10
/
setupApiKey.sh
executable file
·52 lines (45 loc) · 1.44 KB
/
setupApiKey.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
#!/bin/bash
# get current registration
clientId=`grep GOOGLE_DEFAULT_CLIENT_ID /etc/chrome_dev.conf | cut -d "=" -f 2`
clientSecret=`grep GOOGLE_DEFAULT_CLIENT_SECRET /etc/chrome_dev.conf | cut -d "=" -f 2`
apiKey=`grep GOOGLE_API_KEY /etc/chrome_dev.conf | cut -d "=" -f 2`
if [ -n "${apiKey}" ]; then
status="N"
echo API Key has been already registered.
echo
echo "CLIENT_ID: ${clientId}"
echo "CLIENT_SECRET:${clientSecret}"
echo "API_KEY: ${apiKey}"
echo
read -p "Do you want to change API Key?(N/y)" status
if [ ! "y" = ${status} ]; then
exit
fi
fi
status="N"
while [ ! "y" = ${status} ]
do
read -p "Input CLIENT ID:" clientId
read -p "Input CLIENT SECRET:" clientSecret
read -p "Input API KEY:" apiKey
echo
echo "CLIENT ID is " ${clientId}
echo "CLIENT SECRET is " ${clientSecret}
echo "API KEY is " ${apiKey}
echo
read -p "Is this correct?(N/y)" status
done
mount -o remount,rw /
if [ 0 -ne $? ]; then
echo remount root partition failed . Abort.
exit
fi
sed -e '/^GOOGLE_DEFAULT_CLIENT_ID/d' -i /etc/chrome_dev.conf
sed -e '/^GOOGLE_DEFAULT_CLIENT_SECRET/d' -i /etc/chrome_dev.conf
sed -e '/^GOOGLE_API_KEY/d' -i /etc/chrome_dev.conf
echo GOOGLE_DEFAULT_CLIENT_ID=${clientId} >> /etc/chrome_dev.conf
echo GOOGLE_DEFAULT_CLIENT_SECRET=${clientSecret} >> /etc/chrome_dev.conf
echo GOOGLE_API_KEY=${apiKey} >> /etc/chrome_dev.conf
echo
echo API Key registered.
echo Please restart your machine.