My favorites | Sign in
Project Home Downloads Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions

Issue 37 attachment: setup.sh (7.5 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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
#!/bin/sh

prepare()
{
# Find hardware type
echo -n "Found hardware type:"
if [ -e "/nmt/apps" ]; then
echo "Popcorn Hour 200/300 series"
hw="new"
else
echo "Popcorn Hour 100 series"
hw="old"
fi

# Try to correct paths list
path_backup="$PATH";
initial_path=":$PATH:";
new_path="$PATH";
for test_path in $(echo -e "/usr/local/sbin\n/usr/local/bin\n/usr/sbin\n/usr/bin\n/sbin\n/bin\n/usr/games\n/usr/bin\n/bin\n/usr/sbin\n/sbin\n/usr/local/bin\n/usr/X11/bin\n/Applications\n/opt/syb/sigma/bdj/jvm/bin\n/usr/bin/X11\n/opt/syb/app/bin\n/opt/syb/app/sbin\n/opt/syb/sigma/bin\n/nmt/apps"); do
if [[ -d "$test_path" && "$initial_path" != *:$test_path:* ]]; then
echo -e "Information: adding $test_path to your paths list";
new_path="$new_path:$test_path";
fi
done
PATH="$new_path";
export PATH="$new_path";
echo -e "Information: this is your current paths list:\n$PATH";

# Check for Transmission
if [ -d /share/Apps/Transmission ]; then
echo 'Information: transmission is installed';
else
echo 'Error: transmission is not installed, you must install it from CSI before';
fi
# Check for opkg
if [ -f "/usr/local/bin/opkg" ]; then
echo 'Information: opkg is installed';
# Check for an internet connection
if [ "$(wget -qO- -T 5 http://repository.nmtinstaller.com/appinit_version)" != "" ]; then
internet="yes"
echo 'Information: internet connection avaiable';
else
internet="no"
echo 'Warning: no internet connection';
fi
# Try to update opkg
if [ "$internet" == "yes" ]; then
echo 'Information: updating opkg';
opkg update;
wait
else
echo 'Warning: i can not update opkg without internet connection';
fi
# Check for unzip and try to install it
if [ ! -f "/usr/local/bin/unzip" ]; then
echo 'Information: unzip (CSI version) is not installed';
if [ "$internet" == "yes" ]; then
echo 'Installing unzip';
opkg install unzip;
wait;
else
echo 'Error: i can not install unzip without internet connection';
fi
else
echo 'Information: unzip (CSI version) is already installed';
fi
# Check for unrar and try to install it
if [ ! -f "/usr/local/bin/unrar" ]; then
echo 'Information: unrar is not installed';
if [ "$internet" == "yes" ]; then
echo 'Installing unrar'
opkg install unrar;
wait;
else
echo 'Error: i can not install unrar without internet connection';
fi
else
echo 'Information: unrar is already installed';
fi
# Check for wget and try to install it
if [ ! -f "/usr/local/bin/wget" ]; then
echo 'Information: wget (CSI version) is not installed';
if [ "$internet" == "yes" ]; then
echo 'Installing wget'
opkg install wget;
wait;
else
echo 'Error: i can not install wget without internet connection';
fi
else
echo 'Information: wget (CSI version) is already installed';
fi
# Check for bash and try to install it
if [ "$hw" == "old" ]; then
if [ ! -f "/usr/local/bin/bash" ]; then
echo 'Information: bash (CSI version) is not installed';
if [ "$internet" == "yes" ]; then
echo 'Installing bash'
opkg --force-overwrite --force-maintainer install bash;
wait;
else
echo 'Error: i can not install bash without internet connection';
fi
else
echo 'Information: bash (CSI version) is already installed';
fi
fi
# Check for busybox and try to install it
if [ ! -f "/usr/local/bin/busybox" ]; then
echo 'Information: busybox is not installed';
if [ "$internet" == "yes" ]; then
echo 'Installing busybox'
opkg install busybox;
wait;
else
echo 'Error: i can not install busybox without internet connection';
fi
else
echo 'Information: busybox is already installed';
fi
# Install Torrentexpander
if [ "$(opkg status unzip)" != "" ] && [ "$(opkg status unrar)" != "" ] && [[ "$(opkg status wget)" != "" || -f "/bin/wget" ]] && [ "$(opkg status busybox)" != "" ] && [ -d /share/Apps/Transmission ]; then
echo 'Information: torrentexpander setup started';
install;
else
echo 'Error: torrentexpander setup aborted';
export PATH="$path_backup";
fi
else
echo 'Error: opkg not avaiable, you must install local package from CSI before';
export PATH="$path_backup";
fi
}

install()
{
/share/Apps/AppInit/appinit.cgi stop transmission
/share/Apps/AppInit/appinit.cgi webserver_disable
wait

count=0
while [ "$(pgrep transmission-daemon)" ] && [[ $count -lt 60 ]]; do
echo 'Waiting for transmission stop'
sleep 1;
count=$(( count + 1 ));
done

count=0
while [ "$(pgrep -f php5server)" ] && [[ $count -lt 60 ]]; do
echo 'Waiting for php5server stop'
sleep 1;
count=$(( count + 1 ));
done

chmod -R 777 /share/Apps/TorrentExpander/
chown -R nmt:nmt /share/Apps/TorrentExpander/bin/torrentexpander_settings.ini

if [ ! -e /share/Download/Expanded ]; then
mkdir -p /share/Download/Expanded
chmod -R 777 /share/Download/Expanded
chown -R nmt:nmt /share/Download/Expanded
fi

if [ ! -e /share/Video/Movies ]; then
mkdir -p /share/Video/Movies
chmod -R 777 /share/Video/Movies
chown -R nmt:nmt /share/Video/Movies
fi

if [ ! -e /share/Video/Series ]; then
mkdir -p /share/Video/Series
chmod -R 777 /share/Video/Series
chown -R nmt:nmt /share/Video/Series
fi

if [ -f "/share/Apps/Transmission/config/settings.json" ]; then
echo 'Editing transmission config file'
if [ "$hw" == "new" ]; then
sed -i 's/^\( *\)\"script-torrent-done-enabled\"\: .*$/\1\"script-torrent-done-enabled\"\: true\,/g' /share/Apps/Transmission/config/settings.json
sed -i 's/^\( *\)\"script-torrent-done-filename\"\: .*$/\1\"script-torrent-done-filename\"\: \"\/share\/Apps\/TorrentExpander\/bin\/torrentexpander.sh\"\,/g' /share/Apps/Transmission/config/settings.json
fi
if [ "$hw" == "old" ]; then
sed -i 's/^\( *\)\"script-torrent-done-enabled\"\: .*$/\1\"script-torrent-done-enabled\"\: true\,/g' /share/Apps/Transmission/config/settings.json
sed -i 's/^\( *\)\"script-torrent-done-filename\"\: .*$/\1\"script-torrent-done-filename\"\: \"\/usr\/local\/bin\/bash \/share\/Apps\/TorrentExpander\/bin\/torrentexpander.sh\"\,/g' /share/Apps/Transmission/config/settings.json
fi
chmod 666 /share/Apps/Transmission/config/settings.json
chown nmt:nmt /share/Apps/Transmission/config/settings.json
fi

/share/Apps/AppInit/appinit.cgi start transmission
/share/Apps/AppInit/appinit.cgi webserver_enable
wait
}

uninstall()
{
/share/Apps/AppInit/appinit.cgi stop transmission
/share/Apps/AppInit/appinit.cgi webserver_disable
wait;

count=0
while [ $(pgrep transmission-daemon) ] && [[ $count -lt 60 ]]; do
# echo 'Waiting for transmission stop'
sleep 1;
count=$(( count + 1 ));
done

count=0
while [ $(pgrep -f php5server) ] && [[ $count -lt 60 ]]; do
# echo 'Waiting for php5server stop'
sleep 1;
count=$(( count + 1 ));
done

if [ -f /share/Apps/Transmission/config/settings.json ]; then
# echo 'Editing transmission config file'
sed -i 's/^\( *\)\"script-torrent-done-enabled\"\: .*$/\1\"script-torrent-done-enabled\"\: false\,/g' /share/Apps/Transmission/config/settings.json
sed -i 's/^\( *\)\"script-torrent-done-filename\"\: .*$/\1\"script-torrent-done-filename\"\: \"\",/g' /share/Apps/Transmission/config/settings.json
chmod 666 /share/Apps/Transmission/config/settings.json
chown nmt.root /share/Apps/Transmission/config/settings.json
fi

/share/Apps/AppInit/appinit.cgi start transmission
/share/Apps/AppInit/appinit.cgi webserver_enable
wait;
}


case "$1" in
install)
prepare
;;

uninstall)
uninstall
;;
esac
Powered by Google Project Hosting