-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·182 lines (150 loc) · 5.77 KB
/
install.sh
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
#!/usr/bin/env bash
if [ "$(id -u)" != "0" ]; then
echo ">>> This script must be run as 'super user' <<<" 1>&2
[ -z "$(which sudo)" ] && exit 1
sudo -E -H $0 $@
exit $!
fi
PACKAGES="@@PACKAGE@@"
APP_NAME="@@NAME@@"
function usage
{
echo "${0##*/}: installation for @@NAME@@"
echo " ${0##*/} -h"
echo " ${0##*/} [-p <packages>] [-n <application_name>]"
echo "option:"
echo " -h: show this help"
echo " -p: define the packages list to install (default: '$PACKAGES')"
echo " -n: define the application name for shortcut (default: '$APP_NAME')"
exit 0
}
function finish_error
{
msg=$1
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!">&2
echo " Error: $msg">&2
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!">&2
exit 1
}
while getopts "i:p:n:h" opt ; do
case $opt in
p) PACKAGES="$OPTARG"
;;
n) APP_NAME="$OPTARG"
;;
h) usage $0
exit 0
;;
\?) finish_error "Unrecognized parameter -$OPTARG"
;;
:) finish_error "Option -$OPTARG requires an argument."
;;
esac
done
PIP_OPTION="@@PIPOPTION@@"
if [ ! -z "$http_proxy" ]
then
PIP_OPTION="$PIP_OPTION --proxy=$http_proxy"
fi
echo "====== install @@NAME@@ #@@BUILD@@ ======"
echo "install: packages=$PACKAGES application_name=$APP_NAME"
echo
echo "------ check perquisite -------"
echo
if [ ! -z "$(which apt-get 2>/dev/null)" ]; then # DEB linux like
apt-get install -y libxml2-dev libxslt-dev libjpeg-dev libfreetype6 libfreetype6-dev zlib1g-dev
apt-get install -y python3-pip python3-dev
apt-get install -y python3-tk 'python3-imaging|python3-pil'
apt-get install -y pipx python3-dev default-libmysqlclient-dev build-essential pkg-config
else if [ ! -z "$(which dnf 2>/dev/null)" ]; then # RPM unix/linux like
dnf install -y libxml2-devel libxslt-devel libjpeg-devel gcc
dnf install -y libfreetype6 libfreetype6-devel
dnf install -y python3-devel python3-imaging python3-tkinter
else if [ ! -z "$(which yum 2>/dev/null)" ]; then # RPM unix/linux like
yum install -y epel-release
yum install -y libxml2-devel libxslt-devel libjpeg-devel gcc
yum install -y python38-devel python38-imaging python38-tkinter python38-setuptools
easy_install-3.8 pip
else
echo "++++++ Unix/Linux distribution not available for this script! +++++++"
fi; fi; fi
echo
echo "------ configure virtual environment ------"
echo
LUCTERIOS_PATH="/var/lucterios2"
[ -z "$(which "pip3")" ] && echo "No pip3 found!" && exit 1
py_version=$(python3 --version | egrep -o '([0-9]+\.[0-9]+)')
if [ "$py_version" != "3.7" -a "$py_version" != "3.8" -a "$py_version" != "3.9" -a "$py_version" != "3.10" -a "$py_version" != "3.11" ]
then
finish_error "Not Python 3.7, 3.8, 3.9, 3.10 or 3.11 (but $py_version) !"
fi
PYTHON_CMD="python3"
set -e
echo "$PYTHON_CMD -m pip install -U $PIP_OPTION pip==24.0 virtualenv"
$PYTHON_CMD -m pip install -U $PIP_OPTION pip==24.0 virtualenv
mkdir -p $LUCTERIOS_PATH
cd $LUCTERIOS_PATH
echo "$PYTHON_CMD -m virtualenv virtual_for_lucterios"
sudo rm -rf virtual_for_lucterios
$PYTHON_CMD -m virtualenv virtual_for_lucterios
echo
echo "------ install @@NAME@@ ------"
echo
. $LUCTERIOS_PATH/virtual_for_lucterios/bin/activate
pip install -U $PIP_OPTION pip
pip uninstall PIL
pip uninstall Pillow
pip install -U $PIP_OPTION $PACKAGES
[ -z "$(pip list 2>/dev/null | grep 'Django ')" ] && finish_error "Django not installed !"
[ -z "$(pip list 2>/dev/null | grep 'lucterios ')" ]&& finish_error "Lucterios not installed !"
lucterios_admin.py update || lucterios_admin.py refreshall || echo '--no update/refresh--'
[ -f "$LUCTERIOS_PATH/extra_url" ] || echo "# Pypi server" > "$LUCTERIOS_PATH/extra_url"
echo
echo "------ refresh shortcut ------"
echo
rm -rf $LUCTERIOS_PATH/launch_lucterios.sh
touch $LUCTERIOS_PATH/launch_lucterios.sh
echo "#!/usr/bin/env bash" >> $LUCTERIOS_PATH/launch_lucterios.sh
echo >> $LUCTERIOS_PATH/launch_lucterios.sh
echo "export LUCTERIOS_INSTALL='@@BUILD@@'" >> $LUCTERIOS_PATH/launch_lucterios.sh
echo >> $LUCTERIOS_PATH/launch_lucterios.sh
echo ". $LUCTERIOS_PATH/virtual_for_lucterios/bin/activate" >> $LUCTERIOS_PATH/launch_lucterios.sh
echo "cd $LUCTERIOS_PATH/" >> $LUCTERIOS_PATH/launch_lucterios.sh
if [ -z "$LANG" -o "$LANG" == "C" ]
then
echo "export LANG=en_US.UTF-8" >> $LUCTERIOS_PATH/launch_lucterios.sh
fi
qt_version=$($PYTHON_CMD -c 'from PyQt5.QtCore import QT_VERSION_STR;print(QT_VERSION_STR)' 2>/dev/null)
cp $LUCTERIOS_PATH/launch_lucterios.sh $LUCTERIOS_PATH/launch_lucterios_gui.sh
echo "lucterios_gui.py" >> $LUCTERIOS_PATH/launch_lucterios_gui.sh
chmod +x $LUCTERIOS_PATH/launch_lucterios_gui.sh
cp $LUCTERIOS_PATH/launch_lucterios.sh $LUCTERIOS_PATH/launch_lucterios_qt.sh
echo "lucterios_qt.py" >> $LUCTERIOS_PATH/launch_lucterios_qt.sh
chmod +x $LUCTERIOS_PATH/launch_lucterios_qt.sh
echo 'lucterios_admin.py $@' >> $LUCTERIOS_PATH/launch_lucterios.sh
chmod +x $LUCTERIOS_PATH/launch_lucterios.sh
chmod -R ogu+w $LUCTERIOS_PATH
ln -sf $LUCTERIOS_PATH/launch_lucterios.sh /usr/local/bin/launch_lucterios
ln -sf $LUCTERIOS_PATH/launch_lucterios_gui.sh /usr/local/bin/launch_lucterios_gui
ln -sf $LUCTERIOS_PATH/launch_lucterios_qt.sh /usr/local/bin/launch_lucterios_qt
icon_path=$(find "$LUCTERIOS_PATH/virtual_for_lucterios" -name "$APP_NAME.png" | head -n 1)
if [ -d "/usr/share/applications" ]
then
LAUNCHER="/usr/share/applications/lucterios.desktop"
echo "[Desktop Entry]" > $LAUNCHER
echo "Name=$APP_NAME" >> $LAUNCHER
echo "Comment=$APP_NAME installer" >> $LAUNCHER
if [ "${qt_version:0:2}" == "5." ]
then
echo "Exec=$LUCTERIOS_PATH/launch_lucterios_qt.sh" >> $LAUNCHER
else
echo "Exec=$LUCTERIOS_PATH/launch_lucterios_gui.sh" >> $LAUNCHER
fi
echo "Icon=$icon_path" >> $LAUNCHER
echo "Terminal=false" >> $LAUNCHER
echo "Type=Application" >> $LAUNCHER
echo "Categories=Office" >> $LAUNCHER
fi
chmod -R ogu+rw "$LUCTERIOS_PATH"
echo "============ END ============="
exit 0