-
Notifications
You must be signed in to change notification settings - Fork 106
/
package_routines
169 lines (165 loc) · 7.33 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
######################################################################
# 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="{
#}"
#
#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() {
CONF=/etc/config/qpkg.conf
QPKG_NAME="alist"
QPKG_ROOT=`/sbin/getcfg $QPKG_NAME Install_Path -f ${CONF}`
if [ -f "$QPKG_ROOT/data/data.db" ]; then
mv $QPKG_ROOT/data/data.db $QPKG_ROOT/data/_data.db
fi
}
pkg_post_install() {
CONF=/etc/config/qpkg.conf
QPKG_NAME="alist"
QPKG_ROOT=`/sbin/getcfg $QPKG_NAME Install_Path -f ${CONF}`
sqlite3="$QPKG_ROOT/sqlite3"
Ver=3.13.2
chmod -Rf 777 $QPKG_ROOT/alist
if [ -f "$QPKG_ROOT/data/_data.db" ]; then
mv $QPKG_ROOT/data/_data.db $QPKG_ROOT/data/data.db
$sqlite3 $QPKG_ROOT/data/data.db "UPDATE x_setting_items SET value='<div class="markdown-body"><h4>欢迎使用<code>Alist</code>管理云盘空间</h4><table><tbody><tr><td>在线版本</td><td><a href="https://github.com/iranee/qnap-alist-webdav"><img src="https://img.shields.io/github/v/release/iranee/qnap-alist-webdav?color=3\&\label=Releases"></a></td></tr><tr><td>本地版本</td><td><img src="https://img.shields.io/badge/Version-v$Ver-yellowgreen"></td></tr></tbody></table><ul><li>如何使用:<br></a><a href="https://alist.nn.ci/zh/guide/">https://alist.nn.ci/zh/guide</a></li><li><a href="/@login">登录</a> 后进入【<a href="/@manage/storages">管理/存储</a>】<br>页面挂载网盘</li></ul></div>' WHERE key='announcement';"
else
$QPKG_ROOT/alist --force-bin-dir admin
sleep 2
if [ ! -f "$QPKG_ROOT/data/data.db" ]; then
/sbin/log_tool -N "多云盘挂载" -G "Error" -t1 -uSystem -p127.0.0.1 -mlocalhost -a "[多云盘挂载] 无法生成数据库文件,请检查编译版本是否正确,系统构架:$(uname -r)-$(uname -m)。"
else
$sqlite3 $QPKG_ROOT/data/data.db "UPDATE x_users SET password='123456' WHERE username='admin'"
$sqlite3 $QPKG_ROOT/data/data.db "UPDATE x_setting_items SET value='多云盘挂载' WHERE key='site_title';"
$sqlite3 $QPKG_ROOT/data/data.db "UPDATE x_setting_items SET value='<div class="markdown-body"><h4>欢迎使用<code>Alist</code>管理云盘空间</h4><table><tbody><tr><td>在线版本</td><td><a href="https://github.com/iranee/qnap-alist-webdav"><img src="https://img.shields.io/github/v/release/iranee/qnap-alist-webdav?color=3\&\label=Releases"></a></td></tr><tr><td>本地版本</td><td><img src="https://img.shields.io/badge/Version-v$Ver-yellowgreen"></td></tr></tbody></table><ul><li>如何使用:<br></a><a href="https://alist.nn.ci/zh/guide/">https://alist.nn.ci/zh/guide</a></li><li><a href="/@login">登录</a> 后进入【<a href="/@manage/storages">管理/存储</a>】<br>页面挂载网盘</li></ul></div>' WHERE key='announcement';"
sleep 1
fi
fi
mv $QPKG_ROOT/sqlite3 /dev/null
$QPKG_ROOT/alist --force-bin-dir admin
}