-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathiPOS.sh
More file actions
executable file
·223 lines (179 loc) · 6.27 KB
/
iPOS.sh
File metadata and controls
executable file
·223 lines (179 loc) · 6.27 KB
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
219
220
221
222
223
#!/bin/bash
# Instala openBravo POS para Delti
# Leon Ramos et al
# 18/04/2015
#VARIABLES
APT=/usr/bin/apt-get
DEBUG=1
END_USER=vdirectas
END_USER_PASS=vdirectas
MYSQL_ROOT=jittermysql
MYSQL_DB=VDSEMILLA
MYSQL_USR=sistemas
MYSQL_PASS=123qweobp
MYSQL_INIT_DB=VDSEMILLA.sql
MYSQL_TMP=/tmp/iPOS_db.sql.tmp
POS_USR=SEMILLA
POS_PASS=SEMILLA
MYSQL_PASS_C=$(java utils/encrypt ${MYSQL_USR} ${MYSQL_PASS})
POS_TMP=/tmp/iPOS_properties.tmp
POS_PROPERTIES=openbravopos.properties
INST_PATH=/opt/DPOS
#POS_BIN=openbravopos_2.30_bin.zip
#POS_LANG=openbravopos_2.20_es.zip
#POS_BIN=DeltiPOS-2.30.tar.gz
POS_BIN=DeltiPOS-2.30.1.tar.gz
POS="s/{MYSQL_DB}/${MYSQL_DB}/g;s/{MYSQL_USR}/${MYSQL_USR}/g;s/{MYSQL_PASS}/${MYSQL_PASS_C}/g"
RD="s/{MYSQL_DB}/$MYSQL_DB/g;s/{MYSQL_USR}/$MYSQL_USR/g;s/{MYSQL_PASS}/$MYSQL_PASS/g"
MS="s/{MYSQL_DB}/${MYSQL_DB}/g;s/{MYSQL_USR}/${MYSQL_USR}/g;s/{MYSQL_PASS}/${MYSQL_PASS}/g;s/{POS_USR}/${POS_USR}/g;s/{POS_PASS}/${POS_PASS}/g"
HM="s/{HOME_USR}/${END_USER}/g"
STAR_SRC=starcupsdrv-src-3.5.0.tar.gz
STAR_PATH=printer
#FUNCTIONS
function pdebug {
if [ "$DEBUG" == "1" ] ; then
echo "iPOS> $1 " ;
fi
}
function perror {
>&2 echo "ERR> $1 ";
exit 1
}
function checkRoot {
if [ "$(/usr/bin/whoami)" != "root" ] ; then
perror "Not superuser privileges, run with sudo or root user.";
fi
}
function warning {
key=1
while [[ $key =~ ^[^YNn]$ ]] ; do
echo
echo "This script will install OpenBravo POS 2.30"
echo "on an Ubuntu 14.04TLS 32bit system"
echo
echo "WARNING!!! - All previous Data for POS will be erased"
echo
read -p "Are you sure you want to continue? (Y/n) " -n 1 -r
echo
key=$REPLY
done
if [ "$key" != "Y" ] ; then
pdebug "Exiting..."
exit 0
fi
}
function update {
$APT update -y
$APT install vim openssh-server aptitude git libmysql-java mysql-server default-jre tcllib mysqltcl python-mysqldb rdesktop hplip-gui hpijs-ppds hplip phpmyadmin libcups2-dev libcupsimage2-dev -y
$APT remove abiword gnumeric -y
}
function addUser {
ret=false
/usr/bin/getent passwd $END_USER >/dev/null 2>&1 && ret=true
if $ret; then
pdebug "User $END_USER already exists, skipping."
else
pdebug "Creating ${END_USER} user."
/usr/sbin/useradd -s /bin/bash -m -p "`/usr/bin/openssl passwd -1 ${END_USER_PASS}`" ${END_USER}
mkdir -p /home/${END_USER}
chown ${END_USER}.${END_USER} /home/${END_USER}
fi
}
function install {
if [ -d "${INST_PATH}" ] ; then
pdebug "Installation directory ${INST_PATH} exists, erasing."
rm -Rf ${INST_PATH}
fi
pdebug "Creating installation directory ${INST_PATH}"
/bin/mkdir -p ${INST_PATH}
pdebug "Decompresing ${POS_BIN} to ${INST_PATH}..."
#/usr/bin/unzip ${POS_BIN} -d ${INST_PATH}
/bin/tar zxf ${POS_BIN} -C ${INST_PATH}
#pdebug "Decompresing ${POS_LANG} to ${INST_PATH}..."
#/usr/bin/unzip ${POS_LANG} -d ${INST_PATH}
pdebug "Changing permissions."
chmod 755 ${INST_PATH}/start.sh
installShortcut "POS.desktop"
pdebug "Installing ReporteDiario.py"
pdebug "Setting initial data to py script"
sed -e "$RD" ReporteDiario.py > ReporteDiario.py.1
pdebug "Installing py script"
/bin/cp -f ReporteDiario.py.1 /bin/ReporteDiario.py
pdebug "Erasing temporal file"
rm -f ReporteDiario.py.1
pdebug "Setting permissions to py script"
chmod 755 /bin/ReporteDiario.py
pdebug "Installing ReporteCompleto.py"
pdebug "Setting initial data to py script"
sed -e "$RD" ReporteCompleto.py > ReporteCompleto.py.1
pdebug "Installing py script"
/bin/cp -f ReporteCompleto.py.1 /bin/ReporteCompleto.py
pdebug "Erasing temporal file"
rm -f ReporteCompleto.py.1
pdebug "Setting permissions to py script"
chmod 755 /bin/ReporteCompleto.py
installShortcut "ReporteVenta.desktop"
installShortcut "cargarBase.desktop"
# Installing SAP icons
pdebug "Setting initial data to SAP.desktop"
mv shortcuts/SAP.desktop shortcuts/SAP.desktop.1
sed -e "$HM" shortcuts/SAP.desktop.1 > shortcuts/SAP.desktop
installShortcut "SAP.desktop"
pdebug "Erasing temporal file"
rm -f shortcuts/SAP.desktop
mv shortcuts/SAP.desktop.1 shortcuts/SAP.desktop
pdebug "Setting initial data to SAPLocal.desktop"
mv shortcuts/SAPLocal.desktop shortcuts/SAPLocal.desktop.1
sed -e "$HM" shortcuts/SAPLocal.desktop.1 > shortcuts/SAPLocal.desktop
installShortcut "SAPLocal.desktop"
pdebug "Erasing temporal file"
rm -f shortcuts/SAPLocal.desktop
mv shortcuts/SAPLocal.desktop.1 shortcuts/SAPLocal.desktop
}
function installShortcut {
short=${1}
pdebug "Installing shortcut ${short}"
[ -d "/home/${END_USER}/Escritorio" ] && /bin/cp -f shortcuts/${short} /home/${END_USER}/Escritorio
[ -f "/home/${END_USER}/Escritorio/${short}" ] && chmod 755 /home/${END_USER}/Escritorio/${short} && chown ${END_USER}.${END_USER} /home/${END_USER}/Escritorio/${short}
# English support
[ -d "/home/${END_USER}/Desktop" ] && /bin/cp -f shortcuts/${short} /home/${END_USER}/Desktop
[ -f "/home/${END_USER}/Desktop/${short}" ] && chmod 755 /home/${END_USER}/Desktop/${short} && chown ${END_USER}.${END_USER} /home/${END_USER}/Desktop/${short}
}
function setupMysql {
pdebug "Setting initial data to seed file: ${MYSQL_INIT_DB}"
/bin/sed -e "${MS}" ${MYSQL_INIT_DB} > ${MYSQL_TMP}.1
pdebug "Creating initial DB: ${MYSQL_DB}"
/usr/bin/mysql -u root --password=${MYSQL_ROOT} < ${MYSQL_TMP}.1
pdebug "Erasing temporal files"
rm -f ${MYSQL_TMP}.1
pdebug "Setting initial data to ${POS_PROPERTIES}"
/bin/sed -e "${POS}" ${POS_PROPERTIES} > ${POS_TMP}.1
pdebug "Copying ${POS_PROPERTIES} to /home/${END_USER}"
/bin/cp ${POS_TMP}.1 /home/${END_USER}/${POS_PROPERTIES}
chown ${END_USER}.${END_USER} /home/${END_USER}/${POS_PROPERTIES}
pdebug "Erasing temporal files"
rm -f ${POS_TMP}.1
}
function printerInstall {
pdebug "Installing printer..."
pdebug "Creating installation directory ${INST_PATH}/${STAR_PATH}"
/bin/mkdir -p ${INST_PATH}/${STAR_PATH}
pdebug "Decompresing ${STAR_SRC} to ${INST_PATH}/${STAR_PATH}..."
/bin/tar zxf ${STAR_SRC} -C ${INST_PATH}/${STAR_PATH}
CURRENT=$(pwd)
cd ${INST_PATH}/${STAR_PATH}/starcupsdrv
pdebug "Compiling printer modules"
make
make install
cd ${CURRENT}
/usr/bin/service cups restart
}
#LOGIC
checkRoot
warning
update
addUser
install
setupMysql
printerInstall
exit 0