-
-
Notifications
You must be signed in to change notification settings - Fork 21
/
package_routines
218 lines (207 loc) · 7.36 KB
/
package_routines
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
######################################################################
# List of available definitions (it's not necessary to uncomment them)
######################################################################
###### Command definitions #####
#CMD_AWK="/bin/awk"
#CMD_CAT="/bin/cat"
#CMD_CHMOD="/bin/chmod"
#CMD_CHOWN="/bin/chown"
#CMD_CP="/bin/cp"
#CMD_CUT="/bin/cut"
#CMD_DATE="/bin/date"
#CMD_ECHO="/bin/echo"
#CMD_EXPR="/usr/bin/expr"
#CMD_FIND="/usr/bin/find"
#CMD_GETCFG="/sbin/getcfg"
#CMD_GREP="/bin/grep"
#CMD_GZIP="/bin/gzip"
#CMD_HOSTNAME="/bin/hostname"
#CMD_LN="/bin/ln"
#CMD_LOG_TOOL="/sbin/log_tool"
#CMD_MD5SUM="/bin/md5sum"
#CMD_MKDIR="/bin/mkdir"
#CMD_MV="/bin/mv"
#CMD_RM="/bin/rm"
#CMD_RMDIR="/bin/rmdir"
#CMD_SED="/bin/sed"
#CMD_SETCFG="/sbin/setcfg"
#CMD_SLEEP="/bin/sleep"
#CMD_SORT="/usr/bin/sort"
#CMD_SYNC="/bin/sync"
#CMD_TAR="/bin/tar"
#CMD_TOUCH="/bin/touch"
#CMD_WGET="/usr/bin/wget"
#CMD_WLOG="/sbin/write_log"
#CMD_XARGS="/usr/bin/xargs"
#CMD_7Z="/usr/local/sbin/7z"
#
###### System definitions #####
#SYS_EXTRACT_DIR="$(pwd)"
#SYS_CONFIG_DIR="/etc/config"
#SYS_INIT_DIR="/etc/init.d"
#SYS_STARTUP_DIR="/etc/rcS.d"
#SYS_SHUTDOWN_DIR="/etc/rcK.d"
#SYS_RSS_IMG_DIR="/home/httpd/RSS/images"
#SYS_QPKG_DATA_FILE_GZIP="./data.tar.gz"
#SYS_QPKG_DATA_FILE_BZIP2="./data.tar.bz2"
#SYS_QPKG_DATA_FILE_7ZIP="./data.tar.7z"
#SYS_QPKG_DATA_CONFIG_FILE="./conf.tar.gz"
#SYS_QPKG_DATA_MD5SUM_FILE="./md5sum"
#SYS_QPKG_DATA_PACKAGES_FILE="./Packages.gz"
#SYS_QPKG_CONFIG_FILE="$SYS_CONFIG_DIR/qpkg.conf"
#SYS_QPKG_CONF_FIELD_QPKGFILE="QPKG_File"
#SYS_QPKG_CONF_FIELD_NAME="Name"
#SYS_QPKG_CONF_FIELD_VERSION="Version"
#SYS_QPKG_CONF_FIELD_ENABLE="Enable"
#SYS_QPKG_CONF_FIELD_DATE="Date"
#SYS_QPKG_CONF_FIELD_SHELL="Shell"
#SYS_QPKG_CONF_FIELD_INSTALL_PATH="Install_Path"
#SYS_QPKG_CONF_FIELD_CONFIG_PATH="Config_Path"
#SYS_QPKG_CONF_FIELD_WEBUI="WebUI"
#SYS_QPKG_CONF_FIELD_WEBPORT="Web_Port"
#SYS_QPKG_CONF_FIELD_SERVICEPORT="Service_Port"
#SYS_QPKG_CONF_FIELD_SERVICE_PIDFILE="Pid_File"
#SYS_QPKG_CONF_FIELD_AUTHOR="Author"
#SYS_QPKG_CONF_FIELD_RC_NUMBER="RC_Number"
## The following variables are assigned values at run-time.
#SYS_HOSTNAME=$($CMD_HOSTNAME)
## Data file name (one of SYS_QPKG_DATA_FILE_GZIP, SYS_QPKG_DATA_FILE_BZIP2,
## or SYS_QPKG_DATA_FILE_7ZIP)
#SYS_QPKG_DATA_FILE=
## Base location.
#SYS_QPKG_BASE=""
## Base location of QPKG installed packages.
#SYS_QPKG_INSTALL_PATH=""
## Location of installed software.
#SYS_QPKG_DIR=""
## If the QPKG should be enabled or disabled after the installation/upgrade.
#SYS_QPKG_SERVICE_ENABLED=""
## Architecture of the device the QPKG is installed on.
#SYS_CPU_ARCH=""
## Name and location of system shares
#SYS_PUBLIC_SHARE=""
#SYS_PUBLIC_PATH=""
#SYS_DOWNLOAD_SHARE=""
#SYS_DOWNLOAD_PATH=""
#SYS_MULTIMEDIA_SHARE=""
#SYS_MULTIMEDIA_PATH=""
#SYS_RECORDINGS_SHARE=""
#SYS_RECORDINGS_PATH=""
#SYS_USB_SHARE=""
#SYS_USB_PATH=""
#SYS_WEB_SHARE=""
#SYS_WEB_PATH=""
## Path to ipkg or opkg package tool if installed.
#CMD_PKG_TOOL=
#
######################################################################
# All package specific functions shall call 'err_log MSG' if an error
# is detected that shall terminate the installation.
######################################################################
#
######################################################################
# Define any package specific operations that shall be performed when
# the package is removed.
######################################################################
PKG_PRE_REMOVE="{
$CMD_RM -rf ${SYS_QPKG_DIR}/distribution
$CMD_RM -rf ${SYS_QPKG_DIR}/java
}"
#
#PKG_MAIN_REMOVE="{
#}"
#
#PKG_POST_REMOVE="{
#}"
#
######################################################################
# Define any package specific initialization that shall be performed
# before the package is installed.
######################################################################
#pkg_init(){
#}
#
######################################################################
# Define any package specific requirement checks that shall be
# performed before the package is installed.
######################################################################
#pkg_check_requirement(){
#}
#
######################################################################
# Define any package specific operations that shall be performed when
# the package is installed.
######################################################################
#pkg_pre_install(){
#}
#
#pkg_install(){
#}
#
pkg_post_install(){
# Make sure there is no tmp directory and create an empty one
if [ -d ${SYS_QPKG_DIR}/distribution-tmp ]; then
$CMD_RM -rf ${SYS_QPKG_DIR}/distribution-tmp;
fi;
$CMD_MKDIR ${SYS_QPKG_DIR}/distribution-tmp
# Extract new data from tar.gz archive
# extract_data openhab-2.2.0.zip ${SYS_QPKG_DIR}/distribution-tmp
$CMD_7Z x openhab-2.2.0.zip -o${SYS_QPKG_DIR}/distribution-tmp
# Keeping addons, conf and userdata from current install (if existing)
if [ -d ${SYS_QPKG_DIR}/distribution/addons ]; then
$CMD_RM -rf ${SYS_QPKG_DIR}/distribution-tmp/addons;
$CMD_MV ${SYS_QPKG_DIR}/distribution/addons ${SYS_QPKG_DIR}/distribution-tmp/;
fi;
if [ -d ${SYS_QPKG_DIR}/distribution/conf ]; then
$CMD_RM -rf ${SYS_QPKG_DIR}/distribution-tmp/conf;
$CMD_MV ${SYS_QPKG_DIR}/distribution/conf ${SYS_QPKG_DIR}/distribution-tmp/;
fi;
if [ -d ${SYS_QPKG_DIR}/distribution/userdata ]; then
$CMD_RM -rf ${SYS_QPKG_DIR}/distribution-tmp/userdata;
$CMD_MV ${SYS_QPKG_DIR}/distribution/userdata ${SYS_QPKG_DIR}/distribution-tmp/;
fi;
if [ -d ${SYS_QPKG_DIR}/distribution ]; then
$CMD_RM -rf ${SYS_QPKG_DIR}/distribution;
fi;
# Make our tmp directory the final one
$CMD_MV ${SYS_QPKG_DIR}/distribution-tmp ${SYS_QPKG_DIR}/distribution
# Empty variable for choosing a location
USED_PATH=""
# Public share path
OPENHAB_PUBLIC_SHARE_PATH=$SYS_PUBLIC_PATH/openHAB
if [ -d ${OPENHAB_PUBLIC_SHARE_PATH} ]; then
USED_PATH="${OPENHAB_SHARE_PATH}";
fi;
# (Restricted) separate share path
get_share_path "openHAB" OPENHAB_SHARE_PATH
if [ -d ${OPENHAB_SHARE_PATH} ]; then
USED_PATH="${OPENHAB_SHARE_PATH}";
fi;
if [ ! -z "${USED_PATH}" ]; then
# Move conf if needed and symlink it
if [ ! -d ${USED_PATH}/conf ]; then
$CMD_CP -rf ${SYS_QPKG_DIR}/distribution/conf ${USED_PATH};
fi;
# Move addons if needed and symlink it
if [ ! -d ${USED_PATH}/addons ]; then
$CMD_CP -rf ${SYS_QPKG_DIR}/distribution/addons ${USED_PATH};
fi;
# Move userdata if needed and symlink it
if [ ! -d ${USED_PATH}/userdata ]; then
$CMD_CP -rf ${SYS_QPKG_DIR}/distribution/userdata ${USED_PATH};
fi;
# Removing unpacked files and link them to our share
## conf
$CMD_RM -rf ${SYS_QPKG_DIR}/distribution/conf
$CMD_LN -s ${USED_PATH}/conf ${SYS_QPKG_DIR}/distribution/conf
$CMD_CHMOD a+rw -R ${OPENHAB_SHARE_PATH}/conf
## addons
$CMD_RM -rf ${SYS_QPKG_DIR}/distribution/addons
$CMD_LN -s ${USED_PATH}/addons ${SYS_QPKG_DIR}/distribution/addons
$CMD_CHMOD a+rw -R ${USED_PATH}/addons
## userdata
$CMD_RM -rf ${SYS_QPKG_DIR}/distribution/userdata
$CMD_LN -s ${USED_PATH}/userdata ${SYS_QPKG_DIR}/distribution/userdata
$CMD_CHMOD a+rw -R ${USED_PATH}/userdata
fi;
}