1 | #!/bin/sh
|
---|
2 | #
|
---|
3 | # Authors: Skyndas, schorsch100
|
---|
4 | #
|
---|
5 | # Manual script with the use temporary directory
|
---|
6 | #
|
---|
7 | # NOTES: - Dont use \n for new line. \n dont works on enigma 2
|
---|
8 | # - Set manually:
|
---|
9 | # 1. PATH to config files of Oscam
|
---|
10 | # 2. PATH to download the file with picons - only basic folder
|
---|
11 | # 3. TEMP folder
|
---|
12 |
|
---|
13 | # USER SETUP ###############################################
|
---|
14 | # 1.
|
---|
15 | # Set manually PATH to config files without trailing "/"
|
---|
16 | #ConfigPath="/etc/tuxbox/config"
|
---|
17 | #ConfigPath="/usr/keys"
|
---|
18 | ConfigPath="/etc/tuxbox/config"
|
---|
19 | #
|
---|
20 | # 2.
|
---|
21 | # Set manually downloaded file without trailing "/"
|
---|
22 | # Insert basic folder for all picons
|
---|
23 | TrunkUrl="http://www.streamboard.tv/svn/oscam-addons/oscam-picons/picons"
|
---|
24 | #
|
---|
25 | # 3.
|
---|
26 | # Set TEMP folder without trailing "/"
|
---|
27 | TempFolder='/tmp'
|
---|
28 | #
|
---|
29 | # END USER SETUP ###########################################
|
---|
30 |
|
---|
31 | hr='******************************************************************************'
|
---|
32 |
|
---|
33 | # FUNCTIONS ************************************************
|
---|
34 | die() {
|
---|
35 | msg=$1
|
---|
36 | [ -z "$msg" ] && msg="Unknown Error!"
|
---|
37 | echo "$msg"
|
---|
38 | exit 1
|
---|
39 | }
|
---|
40 |
|
---|
41 | parseInfoLocalTxt() {
|
---|
42 | r=$(grep "$1" "$OscamPiconsFolder/$InfoFile" | cut -d':' -f2 | xargs)
|
---|
43 | [ -z "$r" ] && echo "UNKNOWN" || echo "$r"
|
---|
44 | }
|
---|
45 | parseInfoSvnTxt() {
|
---|
46 | r=$(grep "$1" "$TempFolder/$InfoFile" | cut -d':' -f2 | xargs)
|
---|
47 | [ -z "$r" ] && echo "UNKNOWN" || echo "$r"
|
---|
48 | }
|
---|
49 |
|
---|
50 | url() {
|
---|
51 | if [ ! -z "$1" ]; then
|
---|
52 | echo ''
|
---|
53 | echo 'Downloading...'
|
---|
54 | echo "$hr"
|
---|
55 | RESULT=`wget --no-check-certificate "$1" 2>&1`
|
---|
56 | [ "$?" -eq 0 ] && echo "Check Url: OK!" || echo "Check Url: FAILED!"
|
---|
57 | echo $RESULT
|
---|
58 | else
|
---|
59 | die 'Missing URL arguments... exiting!'
|
---|
60 | fi
|
---|
61 | }
|
---|
62 |
|
---|
63 | printHelp() {
|
---|
64 | echo "$0 HELP:"
|
---|
65 | echo ''
|
---|
66 | echo 'THE SCRIPT SUPPORT PARAMETER.'
|
---|
67 | echo "$hr"
|
---|
68 | echo ''
|
---|
69 | echo 'Insert your picons CAID as PARAMETER which you want to download'
|
---|
70 | echo 'Allowed CAID as PARAMETER:'
|
---|
71 | echo 'Skylink: 0D96, 0d96, 0624'
|
---|
72 | echo 'Sky De: 098C, 098c'
|
---|
73 | echo ''
|
---|
74 | echo "$hr"
|
---|
75 | echo 'Script with the use temporary directory for downloaded picons from SVN.'
|
---|
76 | echo ''
|
---|
77 | echo 'For ensure correct operation the script You must be set paths manually in the script.'
|
---|
78 | echo ''
|
---|
79 | echo '1. PATH to config files of Oscam'
|
---|
80 | echo ' ConfigPath="/path/to/oscam/config"'
|
---|
81 | echo '2. PATH to download the file with picons - only basic folder'
|
---|
82 | echo ' TrunkUrl="http://path/to/basic_folder"'
|
---|
83 | echo '3. TEMP folder'
|
---|
84 | echo ' TempFolder="temporary folder"'
|
---|
85 | echo ''
|
---|
86 | exit 0
|
---|
87 | }
|
---|
88 |
|
---|
89 | # PARAMETER ************************************************
|
---|
90 | # unknown or blank parameter = show help (script has parameter)
|
---|
91 | if [ -z "$1" ]; then
|
---|
92 | printHelp
|
---|
93 | exit 1
|
---|
94 | fi
|
---|
95 |
|
---|
96 | setParam() {
|
---|
97 | case "$1" in
|
---|
98 | # Skylink CAID - 0D96, 0624
|
---|
99 | 0D96|0d96)
|
---|
100 | TrunkCaid='0D96'
|
---|
101 | TrunkFile='0D96.zip'
|
---|
102 | InfoFile='info_0D96.txt'
|
---|
103 | ;;
|
---|
104 | # Sky DE CAID - 098C
|
---|
105 | 098C|098c)
|
---|
106 | TrunkCaid='098C'
|
---|
107 | TrunkFile='098C.zip'
|
---|
108 | InfoFile='info_098C.txt'
|
---|
109 | ;;
|
---|
110 | *|''|h|help)
|
---|
111 | printHelp
|
---|
112 | exit 0
|
---|
113 | ;;
|
---|
114 | esac
|
---|
115 | }
|
---|
116 |
|
---|
117 | for PARAM in $*; do
|
---|
118 | setParam "$PARAM"
|
---|
119 | done
|
---|
120 |
|
---|
121 | # UPDATE ***************************************************
|
---|
122 | # Detecting operating system and CPU type
|
---|
123 | MachineHardwareName=$(uname -m)
|
---|
124 |
|
---|
125 | # Validate ConfigPath
|
---|
126 | [ ! -d "$ConfigPath" ] && die "Directory ConfigPath \"$ConfigPath\" not found!"
|
---|
127 | # Validate TempFolder
|
---|
128 | [ ! -d "$TempFolder" ] && die "Directory TempFolder \"$TempFolder\" not found!"
|
---|
129 |
|
---|
130 | # Find setting for oscam httppiconpath folder in file oscam.conf
|
---|
131 | OscamPiconsFolder=$(grep -r httppiconpath $ConfigPath/oscam.conf | cut -d= -f2 | xargs)
|
---|
132 | # Validate OscamPiconsFolder
|
---|
133 | [ ! -d "$OscamPiconsFolder" ] && die "Directory OscamPiconsFolder \"$OscamPiconsFolder\" not found!"
|
---|
134 |
|
---|
135 | # Print to display
|
---|
136 | echo "Preparation before you start the update"
|
---|
137 | echo "$hr"
|
---|
138 | echo "Machine hardware name: "$MachineHardwareName
|
---|
139 | echo "Temp folder: "$TempFolder
|
---|
140 | echo "Config path: "$ConfigPath
|
---|
141 | echo "Oscam picons folder: "$OscamPiconsFolder
|
---|
142 |
|
---|
143 | # Go to TEMP folder
|
---|
144 | cd $TempFolder
|
---|
145 |
|
---|
146 | # Remove the previous downloaded file
|
---|
147 | [ -f "$TrunkFile" ] && rm -f "$TrunkFile"
|
---|
148 |
|
---|
149 | # Download new files
|
---|
150 | url "$TrunkUrl/$TrunkCaid/$TrunkFile"
|
---|
151 | # Validate downloaded file
|
---|
152 | [ ! -s "$TrunkFile" ] && die " Could not download file \"$TrunkFile\"!"
|
---|
153 |
|
---|
154 | # Revison comparision
|
---|
155 | unzip -p $TrunkFile $InfoFile > $InfoFile
|
---|
156 | if [ -s "$TempFolder/$InfoFile" ]; then
|
---|
157 | InfoSvnRevision=$(parseInfoSvnTxt "Revision:")
|
---|
158 | fi
|
---|
159 |
|
---|
160 | if [ -s "$OscamPiconsFolder/$InfoFile" ]; then
|
---|
161 | InfoLocalRevision=$(parseInfoLocalTxt "Revision:")
|
---|
162 | fi
|
---|
163 |
|
---|
164 | # Print Info about PREVIOUS version of picons
|
---|
165 | echo ''
|
---|
166 | echo 'Revison comparision'
|
---|
167 | echo "$hr"
|
---|
168 | echo "Number of revision in SVN: $InfoSvnRevision"
|
---|
169 | echo "Number of local revision: $InfoLocalRevision"
|
---|
170 | echo ''
|
---|
171 |
|
---|
172 | if [ "$InfoSvnRevision" -eq "$InfoLocalRevision" ]; then
|
---|
173 | rm -if "$TrunkFile" || die " Could not remove $TrunkFile!"
|
---|
174 | rm -if "$InfoFile" || die " Could not remove $InfoFile!"
|
---|
175 | echo ">>>>> PICONS in your local machine are CURRENT. Nothing to download. <<<<<"
|
---|
176 | exit 0
|
---|
177 | fi
|
---|
178 |
|
---|
179 | if [ "$InfoSvnRevision" -gt "$InfoLocalRevision" ]; then
|
---|
180 | echo "Picons in your local machine are deprecated and will be updated."
|
---|
181 | fi
|
---|
182 |
|
---|
183 | # Move the downloaded file to a oscam PICONS folder
|
---|
184 | [ -f "$TrunkFile" ] && mv -f "$TrunkFile" "$OscamPiconsFolder"
|
---|
185 |
|
---|
186 | # Go to PICONS folder
|
---|
187 | cd $OscamPiconsFolder
|
---|
188 |
|
---|
189 | if [ -s "$InfoFile" ]; then
|
---|
190 | # Print Info about PREVIOUS version of picons
|
---|
191 | InfoRevision=$(parseInfoLocalTxt "Revision")
|
---|
192 | InfoAuthors=$(parseInfoLocalTxt "Authors")
|
---|
193 | InfoDate=$(parseInfoLocalTxt "Date")
|
---|
194 |
|
---|
195 | # Print to display about the PREVIOUS version of picons
|
---|
196 | echo ""
|
---|
197 | echo "Current installed version of picons for CAID-$TrunkCaid:"
|
---|
198 | echo "$hr"
|
---|
199 | echo "Revision: $InfoRevision"
|
---|
200 | echo "Authors: $InfoAuthors"
|
---|
201 | echo "Last Changed Date: $InfoDate"
|
---|
202 | # Remove the previous files
|
---|
203 | # Print to display
|
---|
204 | echo ""
|
---|
205 | echo "Deleting old (unused) files of picons for CAID-$TrunkCaid:"
|
---|
206 | echo "$hr"
|
---|
207 | # Read through the info_0d96.txt file and execute echo command for every filename
|
---|
208 | for i in `cat $InfoFile | egrep -v '^#|^[[:space:]]*$'`; do
|
---|
209 | echo 'removed: '$i;
|
---|
210 | done
|
---|
211 | # Remove files from file list which is containt in info file
|
---|
212 | cat $InfoFile | egrep -v '^#|^[[:space:]]*$' | xargs rm -fr
|
---|
213 | fi
|
---|
214 |
|
---|
215 | # Decompression, remove a compressed file and exit
|
---|
216 | echo ""
|
---|
217 | echo "Uncompressing downloaded zip file..."
|
---|
218 | echo "$hr"
|
---|
219 | unzip -o "$TrunkFile"
|
---|
220 | rm -if "$TrunkFile" || die " Could not remove $TrunkFile!"
|
---|
221 |
|
---|
222 | if [ -s $InfoFile ]; then
|
---|
223 | # Print to display about the NEW installed version of picons
|
---|
224 |
|
---|
225 | InfoRevision=$(parseInfoLocalTxt "Revision:")
|
---|
226 | InfoAuthors=$(parseInfoLocalTxt "Authors:")
|
---|
227 | InfoDate=$(parseInfoLocalTxt "Date:")
|
---|
228 | InfoPicons=$(parseInfoLocalTxt "Picons:")
|
---|
229 | InfoUpdate=$(parseInfoLocalTxt "Update:")
|
---|
230 |
|
---|
231 | echo ''
|
---|
232 | echo 'Downloaded (new installed) version:'
|
---|
233 | echo "$hr"
|
---|
234 | echo "Revision: $InfoRevision"
|
---|
235 | echo "Authors: $InfoAuthors"
|
---|
236 | echo "Last Changed Date: $InfoDate"
|
---|
237 | echo "Number of Picons: $InfoPicons"
|
---|
238 | echo "Info About The Latest Update: $InfoUpdate"
|
---|
239 | echo ''
|
---|
240 | echo "Files:"
|
---|
241 | echo "$hr"
|
---|
242 | # Size without file IC_......tpl. These are files with picons.
|
---|
243 | ls -l $OscamTplFolder | grep -v '\IC_*.tpl$'
|
---|
244 | fi
|
---|
245 |
|
---|
246 | # Done all OK
|
---|
247 | exit 0 |
---|