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 (5.2 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
#!/bin/sh

prepare()
{
if [ -f "/usr/local/bin/opkg" ]; then
echo 'Information: opkg is present';
# 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 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 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 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 is already installed';
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)" != "" ] && [ "$(opkg status busybox)" != "" ]; then
echo 'Information: torrentexpander setup started';
install;
else
echo 'Error: torrentexpander setup aborted';
fi
else
echo 'Error: opkg not avaiable, you must install local package from CSI before';
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 nmt:nmt /share/Apps/TorrentExpander/bin/torrentexpander_settings.ini

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

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

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

if [ -f "/share/Apps/Transmission/config/settings.json" ]; then
echo 'Editing config file'
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 \$TR_TORRENT_DIR\/\$TR_TORRENT_NAME\"\,/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
}

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 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