-
Notifications
You must be signed in to change notification settings - Fork 5
/
Get-POS
480 lines (467 loc) · 15.9 KB
/
Get-POS
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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
#!/bin/sh
clear
echo "Starting OSPOS Installation Process"
echo "THIS INSTALLATION SHOULD BE RUNNING ON BASE DIRECTORY"
echo "AT $HOME, OUTSIDE PUBLIC_HTML"
echo ""
echo "###########################################################################"
echo "# __ __ ___. _________.__ .__ .__ #"
echo "# / \ / \ ____\_ |__ / _____/| |__ ____ | | | | ______ #"
echo "# \ \/\/ // __ \| __ \ \_____ \ | | \_/ __ \| | | | / ___/ #"
echo "# \ /\ ___/| \_\ \/ \| Y \ ___/| |_| |__\___ \ #"
echo "# \__/\ / \___ >___ /_______ /|___| /\___ >____/____/____ > #"
echo "# \/ \/ \/ \/ \/ \/ \/ #"
echo "# WS - OS POS Auto Installer #"
echo "###########################################################################"
progress () {
add() {
echo "$(( $1 + $2 ))"
}
# Configuration
f=1
s=0
str="[##########]"
fmt="%-25s"
TXT="Extracting..."
tmpfile="/tmp/get_pos_tmpfile"
while true; do
for i in {1..14}; do
sleep "$f"
s=$(add "$s" "$f")
printf "\r${fmt}[%-13s%s" "${TXT#*]}" "${str:0:$i}" "] Estimated Time: ${s}s" | tee "$tmpfile"
done
done
}
progress_bar() {
if [ ! -z "${3}" ]; then
echo ${3}
echo "\"arg1\" \"[arg2]\""
exit 1
fi
main_progress "${1}" "${2}"
}
main_progress() {
local TXT="${2}"
local fmt=$(echo "$TXT" | sed -n 's/^\[\(%\?.[^]]*s\).*/\1/p')
local fmt=${fmt:-%s}
local bg_process="${1}"
local tmpfile=$(mktemp -t progress.XXXXXXXX)
while true; do progress "${TXT}" ${fmt}; done &
${bg_process} &>/dev/null
local total_time="$(sed -n 's/.*:\(.*s\)/\1/p' ${tmpfile})"
total_time=${total_time:-" 0.00s"}
printf "\r${fmt}[%-13s%s\n" "${TXT#*]}" "########################" "] Estimated Time:${total_time}"
rm -f ${tmpfile}
kill $!; trap 'kill $!' SIGTERM SIGINT
}
spinner() {
local info="$1"
local pid=$!
local delay=0.75
local spinstr='|/-\'
while kill -0 $pid 2> /dev/null; do
local temp=${spinstr#?}
printf " [%c] $info" "$spinstr"
local spinstr=$temp${spinstr%"$temp"}
sleep $delay
local reset="\b\b\b\b\b\b"
for ((i=1; i<=$(echo $info | wc -c); i++)); do
reset+="\b"
done
printf $reset
done
printf " \b\b\b\b"
}
if [ "$1" = "" ];
then echo ""
echo "What would you like us to help you with ?"
echo "#########################################"
echo "Please input number of your choice, ex: 2 For Local Deployment"
echo ""
while true
do
select choice in "Web Server Configuration & Setup" "Local Deployment" "Display System Info" "Exit"
do
case $choice in
"Web Server Configuration & Setup")
echo "This isn't ready yet! Please check it back later..."
break
;;
"Local Deployment")
select sub_choice in "FreeBSD Ubuntu CentOS" "Raspberry PI" "cPanel/Online" "Back to Main Menu"
do
case $sub_choice in
"FreeBSD Ubuntu CentOS")
echo "Preparing Ubuntu/CentOS Installation!"
echo ""
echo "Cleaning current directory from previous files!"
rm -rf ~/public_html/OSPOSBK
mv ~/public_html/OSPOS ~/public_html/OSPOSBK
rm -rf OSPOS
echo ""
rm -rf OSPOS.zip & spinner "Removing Files..."
echo ""
echo "OSPOS Retail POS ( OSPOS ) Setup will now start in $HOME Directory..."
echo ""
echo "Loading ====> 20 % "
echo ""
echo "**************************************************"
echo ""
echo "Welcome To OSPOS, OpenSourcePOS Installer"
echo ""
curl -L "https://github.com/opensourcepos/opensourcepos/releases/download/3.3.8/opensourcepos.3.3.8.ffe492.zip" -o OSPOS.zip
echo ""
unzip -qq OSPOS.zip -d OSPOS & progress_bar "sleep 4" "Extracting Files"
echo ""
rm -rf OSPOS.zip & spinner "Removing Zip Files..."
echo ""
echo "Copying files & installing scripts"
echo ""
echo "Loading =======> 44 % "
echo ""
echo "**************************************************"
echo ""
echo "OSPOS Retail POS Has Been Successfully Installed In Your Home Dir Under $HOME/OSPOS"
echo ""
echo "If You Like Our Automated System Can Generate The DB Files For You"
echo
echo -n ">> Shall We Help You Create The DB Files (Y/N)?"
echo
cd
read answer
if test "$answer" != "Y" -a "$answer" != "y";
then exit 0;
else
echo
echo "Please fill in the needed configuration for MySQL connection"
echo ""
echo ">> MySQL DataBase Name?"
read dbname
echo
echo ">> MySQL DataBase Username?"
read usernames
echo
echo ">> MySQL User Password?"
read passwd
echo
echo ">> What's Your Hostname?"
read hostname
echo
echo "Creating Database Files Now..."
echo ""
echo "Loading ==============> 60 % "
echo ""
mv OSPOS/application/config/database.php OSPOS/application/config/database.php.bk
touch OSPOS/application/config/database.php
echo "<?php" >> $HOME/OSPOS/application/config/database.php
echo "defined('BASEPATH') OR exit('No direct script access allowed');" >> $HOME/OSPOS/application/config/database.php
echo "\$active_group = 'default';" >> $HOME/OSPOS/application/config/database.php
echo "\$query_builder = TRUE;" >> $HOME/OSPOS/application/config/database.php
echo "\$db['default'] = array(" >> $HOME/OSPOS/application/config/database.php
echo " 'dsn' => ''," >> $HOME/OSPOS/application/config/database.php
echo " 'hostname' => 'localhost'," >> $HOME/OSPOS/application/config/database.php
echo " 'username' => '$(whoami)_$usernames'," >> $HOME/OSPOS/application/config/database.php
echo " 'password' => '$passwd'," >> $HOME/OSPOS/application/config/database.php
echo " 'database' => '$(whoami)_$dbname'," >> $HOME/OSPOS/application/config/database.php
echo " 'dbdriver' => 'mysqli'," >> $HOME/OSPOS/application/config/database.php
echo " 'dbprefix' => 'ospos_'," >> $HOME/OSPOS/application/config/database.php
echo " 'pconnect' => FALSE," >> $HOME/OSPOS/application/config/database.php
echo " 'db_debug' => (ENVIRONMENT !== 'production')," >> $HOME/OSPOS/application/config/database.php
echo " 'cache_on' => FALSE," >> $HOME/OSPOS/application/config/database.php
echo " 'cachedir' => ''," >> $HOME/OSPOS/application/config/database.php
echo " 'char_set' => 'utf8'," >> $HOME/OSPOS/application/config/database.php
echo " 'dbcollat' => 'utf8_general_ci'," >> $HOME/OSPOS/application/config/database.php
echo " 'swap_pre' => ''," >> $HOME/OSPOS/application/config/database.php
echo " 'encrypt' => FALSE," >> $HOME/OSPOS/application/config/database.php
echo " 'compress' => FALSE," >> $HOME/OSPOS/application/config/database.php
echo " 'stricton' => FALSE," >> $HOME/OSPOS/application/config/database.php
echo " 'failover' => array()," >> $HOME/OSPOS/application/config/database.php
echo " 'save_queries' => TRUE" >> $HOME/OSPOS/application/config/database.php
echo ");" >> $HOME/OSPOS/application/config/database.php
fi
echo "**************************************************"
echo ""
echo "Database Config Files Created Successfully!"
echo "Available under $HOME/OSPOS/application/config/ as database.php"
echo ""
echo "**************************************************"
echo ""
echo -n ">> Do You Want To Create & Import OSPOS Default DB (Y/N)?"
echo
read answer
if test "$answer" != "Y" -a "$answer" != "y";
then exit 0;
else
echo ""
echo ">>Enter SQL privileged password for user:"
echo $(whoami)
read -s rootpwd
echo ""
mysql -u $(whoami) -p$rootpwd --execute="CREATE SCHEMA $(whoami)_$dbname;" 2> /tmp/error1
STATUS=$?
if [ $STATUS -eq 0 ];
then
echo -e "MySQL Database & User Created Successfully!"
elif (grep -i "^ERROR 1007" /tmp/error1 > /dev/null);
then
echo -e "MySQL Database '$(whoami)_$dbname' already exists"
echo -e "Please repeat the above process using dbname different from '$(whoami)_$dbname'"
exit
else
echo -e "Failed to Create Database '$(whoami)_$dbname'"
echo -e "Please check your credentials"
exit
fi
mysql -u $(whoami) -p$rootpwd --execute="CREATE USER '$(whoami)_$usernames'@'%' IDENTIFIED BY '$passwd';" 2> /tmp/error1
mysql -u $(whoami) -p$rootpwd --execute="GRANT ALL PRIVILEGES ON $(whoami)_$dbname . * TO '$(whoami)_$usernames'@'%' IDENTIFIED BY '$passwd' WITH GRANT OPTION;" 2> /tmp/error1
mysql -u $(whoami) -p$rootpwd --execute="FLUSH PRIVILEGES;" 2> /tmp/error1
rm -r /tmp/error1
echo ""
echo "Importing Default DB Values..."
mysql -hlocalhost -u $(whoami)_$usernames -p$passwd $(whoami)_$dbname < $HOME/OSPOS/database/database.sql &>/dev/null & spinner
echo ""
echo ""
#echo "$count"
echo "47 SQL Tables Created"
echo ""
fi
echo "Removing Installation Files"
cp -R $HOME/OSPOS $HOME/public_html/OSPOS/
rm -rf $HOME/OSPOS
rm -rf WS-OSPOS-Installer*
echo "Loading ======================> 100 % "
echo ""
echo "**************************************************"
echo ""
echo "If You filled in the needed, The Installation Of"
echo "OSPOS Should Be Running Now On:"
echo ""
echo "https://$hostname/OSPOS/public"
echo ""
echo "Use below credentials in order to login to our POS"
echo ""
echo "Username: admin"
echo "Password: pointofsale"
echo ""
echo "Please keep the DB credentials safe!"
echo ""
echo "Database: $(whoami)_$dbname"
echo "Username: $(whoami)_$usernames"
echo "Password: $passwd"
echo
echo "**************************************************"
echo
echo "Enjoy Our Retail Solution OSPOS"
echo " https://ospos.wshells.net"
echo
break
;;
"Raspberry PI")
echo "This isn't ready yet! Please check it back later..."
break
;;
"cPanel/Online")
echo "Preparing FreeBSD/cPanel Installation!"
echo ""
echo "Cleaning current directory from previous files!"
rm -rf ~/public_html/OSPOSBK
mv ~/public_html/OSPOS ~/public_html/OSPOSBK
rm -rf OSPOS
echo ""
rm -rf OSPOS.zip & spinner "Removing Files..."
echo ""
echo "OSPOS Retail POS ( OSPOS ) Setup will now start in $HOME Directory..."
echo ""
echo "Loading ====> 20 % "
echo ""
echo "**************************************************"
echo ""
echo "Welcome To OSPOS, OpenSourcePOS Installer"
echo ""
curl -L "https://github.com/opensourcepos/opensourcepos/releases/download/3.3.8/opensourcepos.3.3.8.ffe492.zip" -o OSPOS.zip
echo ""
unzip -qq OSPOS.zip -d OSPOS & progress_bar "sleep 4" "Extracting Files"
echo ""
rm -rf OSPOS.zip & spinner "Removing Zip Files..."
echo ""
echo "Copying files & installing scripts"
echo ""
echo "Loading =======> 44 % "
echo ""
echo "**************************************************"
echo ""
echo "OSPOS Retail POS Has Been Successfully Installed In Your Home Dir Under $HOME/OSPOS"
echo ""
echo "If You Like Our Automated System Can Generate The DB Files For You"
echo
echo -n ">> Shall We Help You Create The DB Files (Y/N)?"
echo
cd
read answer
if test "$answer" != "Y" -a "$answer" != "y";
then exit 0;
else
echo
echo "Please fill in the needed configuration for MySQL connection"
echo ""
echo ">> MySQL DataBase Name?"
read dbname
echo
echo ">> MySQL DataBase Username?"
read usernames
echo
echo ">> MySQL User Password?"
read passwd
echo
echo ">> What's Your Hostname?"
read hostname
echo
echo "Creating Database Files Now..."
echo ""
echo "Loading ==============> 60 % "
echo ""
mv OSPOS/application/config/database.php OSPOS/application/config/database.php.bk
touch OSPOS/application/config/database.php
echo "<?php" >> $HOME/OSPOS/application/config/database.php
echo "defined('BASEPATH') OR exit('No direct script access allowed');" >> $HOME/OSPOS/application/config/database.php
echo "\$active_group = 'default';" >> $HOME/OSPOS/application/config/database.php
echo "\$query_builder = TRUE;" >> $HOME/OSPOS/application/config/database.php
echo "\$db['default'] = array(" >> $HOME/OSPOS/application/config/database.php
echo " 'dsn' => ''," >> $HOME/OSPOS/application/config/database.php
echo " 'hostname' => 'localhost'," >> $HOME/OSPOS/application/config/database.php
echo " 'username' => '$(whoami)_$usernames'," >> $HOME/OSPOS/application/config/database.php
echo " 'password' => '$passwd'," >> $HOME/OSPOS/application/config/database.php
echo " 'database' => '$(whoami)_$dbname'," >> $HOME/OSPOS/application/config/database.php
echo " 'dbdriver' => 'mysqli'," >> $HOME/OSPOS/application/config/database.php
echo " 'dbprefix' => 'ospos_'," >> $HOME/OSPOS/application/config/database.php
echo " 'pconnect' => FALSE," >> $HOME/OSPOS/application/config/database.php
echo " 'db_debug' => (ENVIRONMENT !== 'production')," >> $HOME/OSPOS/application/config/database.php
echo " 'cache_on' => FALSE," >> $HOME/OSPOS/application/config/database.php
echo " 'cachedir' => ''," >> $HOME/OSPOS/application/config/database.php
echo " 'char_set' => 'utf8'," >> $HOME/OSPOS/application/config/database.php
echo " 'dbcollat' => 'utf8_general_ci'," >> $HOME/OSPOS/application/config/database.php
echo " 'swap_pre' => ''," >> $HOME/OSPOS/application/config/database.php
echo " 'encrypt' => FALSE," >> $HOME/OSPOS/application/config/database.php
echo " 'compress' => FALSE," >> $HOME/OSPOS/application/config/database.php
echo " 'stricton' => FALSE," >> $HOME/OSPOS/application/config/database.php
echo " 'failover' => array()," >> $HOME/OSPOS/application/config/database.php
echo " 'save_queries' => TRUE" >> $HOME/OSPOS/application/config/database.php
echo ");" >> $HOME/OSPOS/application/config/database.php
fi
echo "**************************************************"
echo ""
echo "Database Config Files Created Successfully!"
echo "Available under $HOME/OSPOS/application/config/ as database.php"
echo ""
echo "**************************************************"
echo ""
echo -n ">> Do You Want To Create & Import OSPOS Default DB (Y/N)?"
echo
read answer
if test "$answer" != "Y" -a "$answer" != "y";
then exit 0;
else
echo ""
echo "MySQL Database & User Created Successfully!"
echo ""
echo "Importing Default DB Values..."
echo ""
/usr/bin/uapi Mysql create_database name=$(whoami)_$dbname > /dev/null 2>&1
/usr/bin/uapi Mysql create_user name=$(whoami)_$usernames password=$passwd > /dev/null 2>&1
/usr/bin/uapi Mysql set_privileges_on_database user=$(whoami)_$usernames database=$(whoami)_$dbname privileges=ALL%20PRIVILEGES > /dev/null 2>&1
mysql -hlocalhost -u $(whoami)_$usernames -p$passwd $(whoami)_$dbname < $HOME/OSPOS/database/database.sql &>/dev/null & spinner
echo ""
echo "47 SQL Tables Created"
echo ""
fi
echo "Removing Installation Files"
cp -R $HOME/OSPOS $HOME/public_html/OSPOS/
rm -rf $HOME/OSPOS
rm -rf WS-OSPOS-Installer*
echo "Loading ======================> 100 % "
echo ""
echo "**************************************************"
echo ""
echo "If You filled in the needed, The Installation Of"
echo "OSPOS Should Be Running Now On:"
echo ""
echo "https://$hostname/OSPOS/public"
echo ""
echo "Use below credentials in order to login to our POS"
echo ""
echo "Username: admin"
echo "Password: pointofsale"
echo ""
echo "Please keep the DB credentials safe!"
echo ""
echo "Database: $(whoami)_$dbname"
echo "Username: $(whoami)_$usernames"
echo "Password: $passwd"
echo
echo "**************************************************"
echo
echo "Enjoy Our Retail Solution OSPOS"
echo " https://ospos.wshells.net"
echo
break
;;
"Back to Main Menu")
echo "Back to Main Menu..."
break 2
;;
*)
echo "Invalid Entry, stop messing around monkey."
break 2
;;
esac
done
break
;;
"WindowsXP")
echo "Windows XP doesn't support shell installation idiot!" & echo "Exiting now..."
break
;;
"Display System Info")
echo "System Info"
echo "#########################################"
echo ""
uname -a
echo ""
echo ">>Apache:"
echo ""
#httpd -v
echo ""
echo ">>PHP Version:"
echo ""
php -v
echo ""
echo ">>DB Version:"
echo ""
#mysqld --version
echo ""
echo "#########################################"
echo ""
break
;;
"Exit")
echo "Exiting Now..."
exit 0
break
;;
*)
echo "Invalid entry, stop messing around monkey."
break
;;
esac
done
done
exit 0
fi
-
#
# · All rights reserved © 2010 - 2023 ·
# [WebShells Services](https://www.wshells.ws) & [Open Source Point of Sale](https://opensourcepos.org)
#
# This Script was created for OSPOS ( OpensourcePOS ) project exclusively.
# Redistributing, using, modifying, or claiming ownership for any type of usage is totally prohibited/restricted.
# Any person or company found breaching the license agreement will have a bunch of monkeys at the door ready to destroy their servers.