forked from sndirsch/ingress-ice
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathingress-ice.sh
executable file
·169 lines (155 loc) · 4.53 KB
/
ingress-ice.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
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
#!/bin/bash
# ingress-ice start script by Nikitakun
# Launch this script from console ( $ chmod +x ingress-ice&&./ingress-ice )
FILE="$HOME/.ingress-ice.conf"
SCRIPT_HOME=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
COUNT=""
MACHINE_TYPE=`uname -m`
PHANTOMJS="$SCRIPT_HOME/phantomjs"
PHANTOMJS_FLAGS="--ignore-ssl-errors=true"
if (command -v dialog >/dev/null)
then
DIALOG=${DIALOG=dialog}
else
if (command -v whiptail >/dev/null)
then
DIALOG=${DIALOG=whiptail}
else
TEXT=true
fi
fi
launch() {
if [ -f "$1" ]
then
clear
if [ "$2" = "0" ]; then
echo "Existing config file found ($1). Starting ice..."
else
echo "Existing config file found ($1). Starting ice... (Take $2 screenshots)"
fi
if (command -v notify-send >/dev/null)
then
notify-send "Ingress Ice" "ICE is running"
fi
ARGS="$1 $2"
if [ ! $LOOP ]
then
$PHANTOMJS $PHANTOMJS_FLAGS "$SCRIPT_HOME/ice/ice.js" $ARGS; exit;
else
while :; do
$PHANTOMJS $PHANTOMJS_FLAGS "$SCRIPT_HOME/ice/ice.js" $ARGS
done
fi
else
if [ ! $TEXT ]; then
$DIALOG --backtitle "Automatic screenshooter for ingress intel map" --title "Ingress Ice" --clear \
--yesno "Config file for Ice not found. Create one?" 8 36
case $? in
0) user_input $1 $2; break;;
1) clear
echo "Config file is mandatory. Exiting..."
exit;;
255) clear; exit;;
esac
else
while true; do
echo "Ingress ICE, Automatic screenshooter for ingress intel map"
read -p "Config file not found ($1). Create one? (y/n) " yn
case $yn in
[Yy]* ) user_input $1 $2; break;;
[Nn]* ) clear;echo "Config file is mandatory. Exiting..."; exit;;
* ) echo "Please answer y(es) or n(o).";;
esac
done
fi
fi
}
echo_help() {
echo "Ingress ICE"
echo ""
echo "Usage:"
echo " ingress-ice.sh [-c 100] [-i settings.txt] [-r]"
echo " ingress-ice.sh -h | -?"
echo " ingress-ice.sh -a"
echo ""
echo "Options:"
echo " -h -? Show this help"
echo " -r Edit your configuration"
echo " -a Show authors"
echo " -c <count> Take <count> screenshots"
echo " -i <file> Read settings from <file> or create config if not exists"
echo " -o Delete old config and configure ice from scratch"
echo " -s Run Ingress ICE in an endless loop (it will restart automatically after an error)"
echo ""
echo "Please visit https://ingress.netlify.com/ for more information"
exit;
}
user_input() {
if [ ! -f "$1" ]; then
cp "$SCRIPT_HOME/ice/ingress-ice.conf.sample" $1
fi
if [ ! $TEXT ]; then
$DIALOG --title "Notice" --msgbox "I've created a sample config for you. You will be redirected to a text editor.\nEnter your settings there (don't forget to save it!) and close the editor.\n\nIce will start automatically." 12 50;
if [ -z "$EDITOR" ] || [ "x$EDITOR" == "x" ]
then
nano $1
else
$EDITOR $1
fi
launch $1 $2
else
echo "I've created a sample config for you. You will be redirected to a text editor (\$EDITOR or nano). Enter your settings there (don't forget to save it!) and close the editor. Ice will start automatically."
if [ -z "$EDITOR" ]
then
nano $1
else
$EDITOR $1
fi
launch $1 $2
fi
}
OPTIND=1
NFILE=""
COUNT=""
while getopts "h?rolsc:ai:" opt; do
case "$opt" in
h|\?) echo_help;;
i) NFILE=$OPTARG;;
a) if [ ! $TEXT ]; then
$DIALOG --title "Credits" --msgbox "Ingress ICE (Distributed under the MIT License)\n\nAuthors:\n https://ingress.netlify.com" 16 52;exit;
else
echo "Ingress ICE (Distributed under the MIT License)"
echo ""
echo "Authors:"
echo " https://ingress.netlify.com"
exit;
fi;;
o) if [ -z "$NFILE" ]; then
NFILE=$FILE
fi
rm $NFILE
if [ -z "$COUNT" ]; then
COUNT=0
fi
user_input $NFILE $COUNT; break;;
c) COUNT=$OPTARG;;
l) TEXT=true;;
r) if [ -z "$NFILE" ]; then
NFILE=$FILE
fi
if [ -z "$COUNT" ]; then
COUNT=0
fi
user_input $NFILE $COUNT; break;;
s) LOOP=true;;
esac
done
shift $((OPTIND-1))
[ "$1" = "--" ] && shift
if [ -z "$NFILE" ]; then
NFILE=$FILE
fi
if [ -z "$COUNT" ]; then
COUNT=0
fi
launch $NFILE $COUNT