1 | #!/bin/sh
|
---|
2 | #
|
---|
3 | # Automatic script for find folder and downloaded file.
|
---|
4 | # It works without the use of a temporary directory
|
---|
5 | #
|
---|
6 | # This script will be it tested on:
|
---|
7 | # Vu+ Solo, i686 (Xubuntu), x86_64, raspberry pi (armv6l), .....
|
---|
8 | #
|
---|
9 | # NOTES: - Dont use \n for new line. \n dont works on enigma 2
|
---|
10 | # - Set manually only way to download the file in USER SETUP
|
---|
11 |
|
---|
12 | # USER SETUP ###############################################
|
---|
13 | # Set manually downloaded file without trailing "/"
|
---|
14 |
|
---|
15 | TrunkUrl="http://www.streamboard.tv/svn/oscam-addons/oscam-template/Envi_template/branches/compressed_files"
|
---|
16 | TrunkFile='Envi_Template.zip'
|
---|
17 |
|
---|
18 | # END USER SETUP ###########################################
|
---|
19 |
|
---|
20 | # FUNCTIONS ************************************************
|
---|
21 | die() {
|
---|
22 | msg=$1
|
---|
23 | [ -z "$msg" ] && msg="Unknown Error!"
|
---|
24 | echo "$msg"
|
---|
25 | exit 1
|
---|
26 | }
|
---|
27 |
|
---|
28 | # UPDATE ***************************************************
|
---|
29 | # Detecting operating system and CPU type
|
---|
30 | MachineHardwareName=$(uname -m)
|
---|
31 |
|
---|
32 | # Print to display
|
---|
33 | echo ""
|
---|
34 | echo "Preparation before downloading the file"
|
---|
35 | echo "---------------------------------------"
|
---|
36 |
|
---|
37 | # Find PATH with config files
|
---|
38 | # Find file oscam.version which contains path with config files
|
---|
39 | FindPath=$(find / -name "oscam.version" -print | xargs |sed -r 's/.{14}$//' )
|
---|
40 |
|
---|
41 | # Validate FindPath
|
---|
42 | [ ! -d "$FindPath" ] && die "Directory FindPath \"$FindPath\" not found!"
|
---|
43 |
|
---|
44 | # Find path with config files
|
---|
45 | ConfigPath=$(grep -r ConfigDir $FindPath/oscam.version | cut -d':' -f2 | xargs)
|
---|
46 | ConfigPath=$(echo "$ConfigPath" |sed 's/.$//')
|
---|
47 |
|
---|
48 | # Validate ConfigPath
|
---|
49 | [ ! -d "$ConfigPath" ] && die "Directory ConfigPath \"$ConfigPath\" not found!"
|
---|
50 |
|
---|
51 | # Print to display
|
---|
52 | echo "Found path with oscam.version: "$FindPath
|
---|
53 | echo "Found folder with oscam.conf: "$ConfigPath
|
---|
54 |
|
---|
55 | # Find setting for oscam httptpl folder in file oscam.conf
|
---|
56 | OscamTplFolder=$(grep -r httptpl $ConfigPath/oscam.conf | cut -d= -f2 | xargs)
|
---|
57 |
|
---|
58 | # Validate OscamTplFolder
|
---|
59 | [ ! -d "$OscamTplFolder" ] && die "Directory OscamTplFolder \"$OscamTplFolder\" not found!"
|
---|
60 |
|
---|
61 | # Correction if last character of OscamTplFolder is blank
|
---|
62 | stringvar=$(echo $OscamTplFolder | tail -c 2)
|
---|
63 | if [ $stringvar = "/" ]; then
|
---|
64 | echo "Oscam template folder is in the right format"
|
---|
65 | else
|
---|
66 | OscamTplFolder="$OscamTplFolder/"
|
---|
67 | echo "Oscam template folder was corrected to the right format: "$OscamTplFolder
|
---|
68 | fi
|
---|
69 |
|
---|
70 | # Go to TPL folder
|
---|
71 | cd $OscamTplFolder
|
---|
72 |
|
---|
73 | # Remove the previous downloaded file
|
---|
74 | [ -f "$TrunkFile" ] && rm -f "$TrunkFile"
|
---|
75 |
|
---|
76 | # Download new files
|
---|
77 | url(){
|
---|
78 | if [ ! -z "$1" ]; then
|
---|
79 | wget -q --no-check-certificate "$1"
|
---|
80 | [ "$?" -eq 0 ] && echo "Check Url: $1 exists..." || echo "Check Url: $1 doesn't exists.."
|
---|
81 | else
|
---|
82 | echo "No Arguments..exiting" & exit 1
|
---|
83 | fi
|
---|
84 | }
|
---|
85 |
|
---|
86 | url "$TrunkUrl/$TrunkFile"
|
---|
87 |
|
---|
88 | # Print to display
|
---|
89 | echo ""
|
---|
90 | echo "START SCRIPT TO DOWNLOAD THE FILE"
|
---|
91 | echo "---------------------------------"
|
---|
92 | echo ""
|
---|
93 | echo "Machine hardware name: "$MachineHardwareName
|
---|
94 | echo "Config path: "$ConfigPath
|
---|
95 | echo "Oscam template folder: "$OscamTplFolder
|
---|
96 |
|
---|
97 | # Validate downloaded file
|
---|
98 | tmpfile=$(echo "$OscamTplFolder" |sed 's/.$//')
|
---|
99 | file="$tmpfile/$TrunkFile"
|
---|
100 | if [ -f "$file" ]
|
---|
101 | then
|
---|
102 | echo "Downloaded file: $file was successfully downloaded"
|
---|
103 | else
|
---|
104 | echo "Downloaded file: $file was not downloaded!!!"
|
---|
105 | exit 1
|
---|
106 | fi
|
---|
107 |
|
---|
108 | # Remove the previous files
|
---|
109 | [ -f CSS.tpl ] && rm -f CSS.tpl
|
---|
110 | [ -f FOOTER.tpl ] && rm -f FOOTER.tpl
|
---|
111 | [ -f HEADERSHORT.tpl ] && rm -f HEADERSHORT.tpl
|
---|
112 | [ -f info.txt ] && rm -f info.txt
|
---|
113 |
|
---|
114 | # Print to display
|
---|
115 | echo ""
|
---|
116 | echo "Old template files have been deleted"
|
---|
117 | echo ""
|
---|
118 | echo "Decompressed files:"
|
---|
119 |
|
---|
120 | # Decompression
|
---|
121 | unzip "$TrunkFile"
|
---|
122 |
|
---|
123 | # Print to display info about Envi
|
---|
124 | InfoRevision=$(grep -r Revision $OscamTplFolder/info.txt | cut -d':' -f2 | xargs)
|
---|
125 | InfoAuthors=$(grep -r Authors $OscamTplFolder/info.txt | cut -d':' -f2 | xargs)
|
---|
126 | InfoDate=$(grep -r Date $OscamTplFolder/info.txt | cut -d':' -f2 | xargs)
|
---|
127 |
|
---|
128 | echo ""
|
---|
129 | echo "INFO ABOUT ENVI"
|
---|
130 | echo "---------------"
|
---|
131 | echo "Envi Revision: $InfoRevision"
|
---|
132 | echo "Authors: $InfoAuthors"
|
---|
133 | echo "Last Changed Date: $InfoDate"
|
---|
134 |
|
---|
135 | # Remove a compressed file
|
---|
136 | rm -if "$TrunkFile" || die "Could not remove $TrunkFile!"
|
---|
137 |
|
---|
138 | # Done all OK
|
---|
139 | exit 0 |
---|