-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcqpweb-instabox.sh
executable file
·5401 lines (4335 loc) · 221 KB
/
cqpweb-instabox.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
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
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
SCRIPTNAME="cqpweb-instabox.sh"
# AUTHOR: Scott Sadowsky
# WEBSITE: www.sadowsky.cl
# DATE: 2019-11-25
# VERSION: 87
# LICENSE: GNU GPL v3
# DESCRIPTION: This script takes an install of certain versions of Ubuntu or Debian and sets up Open
# Corpus Workbench (OCWB) and CQPweb on it. It can also, optionally, install software and
# configure the system for use as a headless server on bare metal, a headless server in
# a virtual machine or a desktop with GUI for linguistic work.
#
# It has been tested on:
# - Ubuntu 18.04 LTS Live Server (the default download, aimed at cloud-based servers)
# - Ubuntu 18.04 LTS Alternative Server (the traditional server)
# - Ubuntu 18.04 LTS Desktop
# - Lubuntu 18.04 Desktop
# - Debian 9.9 Stable (note that newer versions of this script have not been tested on Debian yet).
#
# While I've made every effort to make it work properly, it comes with no guarantees and
# no warranties. Bug reports are most welcome!
# CHANGE LOG:
#
# v87
# - Added more exceptions to /usr/share/modsecurity-crs/rules/RESPONSE-999-EXCLUSION-RULES-AFTER-CRS.conf to
# prevent false positives when using CQPweb. Seems mod_security flags a lot of what CQPweb does as SQL exploits.
# - Added option to customize the titles of CQPweb pages. Set with CUSTPPGTITLES=1.
# - Extended the customizations done to the CQPweb signup page. Set with CUSTPGSIGNUP=1.
# - Added option to use a custom URL for user's own CQP syntax tutorial page. Set with CUSTCQPSYNTUTURL=1.
#
# v86
# - Added option to harden MySQL. Run script with `HARDENMYSQL=1` to use it.
# - Refined mod_evasive configuration.
# - Added a series of rule exceptions to mod_security to prevent false positives (and thus
# breakages and bans) when using various CQPweb functions at paranoia level 2.
# - Added whitelisted IPs to mod_security configuration
# - Increased value of SecPcreMatchLimit and SecPcreMatchLimitRecursion to 500000 each in
# /etc/modsecurity/modsecurity.conf to avoid "Execution error - PCRE limits exceeded (-8)" errors.
#
# v85
# - Added SSL to the server config, using certificates from Let's Encrypt. Set with SSLSW=1.
# - Further improved fail2ban configuration.
# - Vastly increased number of bad bots detected by apache-badbots module.
# - Fixed regression that disabled detection of $ETHERNET.
# - Fixed permissions and ownership of /var/log/apache2/modsec_audit.log
# - Added "Sensible Bash" settings to .bashrc (see <https://github.com/mrzool/bash-sensible>)
# - Configured `nano` using `.nanorc`.
#
# v84
# - Added script to find world-writable files.
# - Added `bat` to server install.
# - Log monitoring aliases and `byobu` screens now use `lnav` instead of `tail`.
# - Added install of `bashmarks`.
# - Implemented a fix for fail2ban's use of Debian paths on Ubuntu.
# - Configured `fail2ban` to ban port scanners logged by UFW and connection attempts over UDP.
#
# v83
# - Modernized and further hardened SSH configuration.
# - Fixed the ancient (2013) apache_badbots version that comes with Ubuntu's fail2ban version. New config
# file is now taken from github, modified and installed.
# - Hardened a good number of sysctl.conf settings.
# - Added GRUB method of disabling ipv6.
# - Modified some php.ini settings. Among other things, errors are now logged to /var/log/php_errors.log
# - Removed MOSH. Great idea, unreliable implementation.
#
# v82
# - Added two new installation options, `vserver` and `vserverdeluxe`, for virtual servers (VPS).
# - Added support for MOSH (MObile SHell), a faster way of doing SSH.
# - Added several monitoring tools to server installs, such as `goaccess`.
# - Fixed error in CIDR notation converter for mod_evasive whitelist.
#
# v81
# - CQPweb: Added installation and configuration of the mod_security and mod_evasive Apache modules (server install).
# - CQPweb: Added installation and configuration of the OWASP mod_security core rule set.
# - OS: Added option to completely disable ipv6 support in host OS. This is set with `DISABLEIPV6=1`.
# - NETWORK: Overhauled the entire installation and configuration of fail2ban to take into account changes
# that have appeared over time. More suggested software for it is also installed now.
# - OS: Removed a few settings in sysctl.conf that have been deprecated.
# - NETWORK: Hardened several SSH configuration options.
# - OS: Added installation of `sysstat` to server install.
# - CQPweb: Fixed three harmless but annoying errors in php.ini (loading gd2 and mysqli extensions improperly).
#
# v80
# - CQPweb: Added URL for CQPweb changelog to version-reporting script.
# - CQPweb: Set all log-monitoring aliases to display the last 25 lines.
# - NETWORK: Lengthened fail2ban bantime and findtime.
# - OS: Added installation of `debsums`, `apt-show-versions` packages.
#
# v79
# - Very minor fixes.
#
# v78
# - INTERNAL: Changed URL for my personal corpora.
# - OS: Added timezone info to test e-mail scripts.
#
# v77
# - CQPweb: Fixed permission issue with /css and /css/img directories.
# - CQPweb: Now creates a script in ~/bin to test the CQPweb/PHP mail server.
# - OS: Midnight commander (mc) is now installed as part of Necessary Software.
#
# v76
# - Changed SourceForce URL to point to the new branch
# - Added autoremove to most package installation commands.
#
# v75
# - Fixed some folder and file ownership/permissions issues.
#
# v74
# - CQP+CWB: Enchanced the version-check script that is created in ~/bin.
#
# v73
# - CQPweb: Removed setting up Postfix mail server from installation presets. While this code does
# indeed install a working mail server, CQPweb does NOT use it, and can't send e-mails
# once it's installed! Downside: server utils like fail2ban now can't send e-mails.
# - CQPweb: Added a confirmation dialog with warning when installing Postfix.
#
# v72
# - CQPweb: Database update script now reloadgs and restarts apache2 after updating.
# - CQPweb: Added option to replace the "Menu" text in the T/L corner of most pages with a custom graphic and a
# user-specified URL (on user home, query and admin pages).
#
# v71
# - CQPweb: The fonts used in concordances are now customizable. A monospace font looks very nice there!
# - All: Added a script to report versions of CQPweb, CWB, etc. (~/bin/version-report.sh).
# - CQPweb: User can now choose to install MySQL 8 rather than the default version. WARNING: CQPweb does
# NOT currently work with MySQL 8.
#
# v70
# - All: Made this script compatible with Debian (tested on Debian 9.9.0 stable). This
# involved more changes than can reasonably be documented here.
# - CQPweb: Modified all code which had a specific PHP version hard-coded. It will now
# detect the current PHP version and do what must be done regardless of the version.
#
#
# v69
# - CQPweb: Refactored code so that favicon and TL/TR image can be uploaded independently.
#
# v68
# - CQPweb: Added ability to customize the font used by modifying all CSS files.
# - CQPweb: Modified upd-all.sh script so it now automatically updates the CQPweb database.
# - CQPweb: Refactored code that creates scripts in ~/bin so it can be run independently of
# the rest of cqpweb-instabox.sh.
#
# v67
# - CQPweb: Added creation of script to upgrade databases.
#
# v66
# - SSH PubKey: SSH Public Key installation routine now installs certain software that would
# otherwise only be installed if user chooses the "server" installation options.
#
# v65
# - CQPweb: Fixed another bug in the offline frequency counting script.
#
# v64
# - CQPweb: Fixed bug in creation of offline frequency counting script (in ~/bin).
#
# v63
# - All: Added metaconfigurations and ability to select them from CLI.
# - CWB+CQPweb Added script to facilitate off-line calculation of frequencies (in ~/bin).
# - CQPweb: Bugfix: Lack of 'sudo' prevented /var/www/html/cqpweb from being created in certain conditions.
# - CWB+CQPweb: Added text telling user what revision is being installed.
# - CQPweb: Added variable to select whether or not to upload top left/right logo, along with variables for
# image source and destination.
#
# v62
# - CQPweb: Adjusted syntax of empty strings in config.inc.php.
# - CQPweb: Added creation of script for sending test e-mails via Postfix (in ~/bin).
# - CQPweb: Added option to modify certain web pages (set CUSTPGSIGNUP=1).
# - CQPweb: Added message to user telling them what IP address to open in browser to use CQPweb.
#
# v61
# - CQPweb: Added install of php-json module.
# Added code to upload favicon.ico to server.
# - Server SW: Added install of 'ripgrep' and 'fd'.
# - Bash config: Added aliases for viewing various logs.
#
# v60
# - Initial release.
#
# v59 and below
# - Pre-release development.
# NOTE:
# - To get the mail server working, the following may be necessary:
# · Replace the entry in /etc/hosts with the following:
# 127.0.0.1 localhost.localdomain localhost other_hostname fully_qualified-domain_name.com
# · Uninstall postfix, and install sendmail and mailutils.
# · Uninstall sendmail and then reinstall it.
################################################################################
# SCRIPT CONFIGURATION
# 0 disables, 1 enables, 2 (or anything else) disables and can mean whatever you
# want (e.g. 2 = "already run", so you can keep track of what you've done).
################################################################################
# SYSTEM CONFIGURATION
UPGRADEOS=0 # Upgrade the OS and all its software packages to the latest versions.
CONFIGSHELL=0 # Change default shell from dash to bash. Prevents certain errors.
CONFIGBASH=0 # Configure .bashrc with some useful things.
CONFIGTZ=0 # Set up time zone.
CONFIGCONSOLE=0 # Configure the console's encoding, fonts, etc.
CONFIGKEYBOARD=0 # Configure the console's keyboard
CONFIGUBUCLOUD=0 # UBUNTU LIVE SERVER 18.04 ONLY: Remove certain cloud-specific components.
CONFIGHOST=0 # UBUNTU LIVE SERVER 18.04 ONLY: Configure host information to fix bug.
# SSH CONFIGURATION
SSHGENNEWKEYS=0 # Generate new SSH keys and moduli. The latter will take around an hour.
SSHPWDSW=0 # Install and configure SSH WITH PASSWORD ACCESS on the server, to allow remote administration.
# WARNING: Do not run SSHPWDSW and SSHKEYSW together! You must copy your SSH public key to the server in between!
SSHKEYSW=0 # Reconfigure the SSH server for access using a PUBLIC KEY instead of a PASSWORD. A true MUST for security!
# Do this only AFTER installing the SSH server with password access and uploading your pubic key to the server!
# MAIN SOFTWARE SETS
NECESSARYSW=0 # Install software necessary for the server to work.
USEFULSW=0 # Install software considered useful (though optional).
SERVERSW=0 # Install server software (monitoring, security and such).
VIRTUALSRV=0 # Set to 1 for virtual servers (VPS). This uninstalls certain hardware-related software.
# CWB+CQPWEB+CORPORA
CQPCWBRELEASE=0 # Install a specific SubVersion release of CWB and CQPweb. "0" downloads latest version.
SHORTSWDIR="software" # The directory in $HOME in which to download/install most software.
COMMONCQPWEBDIR="/usr/local/share/cqpweb" # Common base dir for CQPweb. No trailing slash, please!
NUKECORPORA=0 # Delete ALL installed corpora. Not normally needed!
# CWB
CWB=0 # Install CORPUS WORKBENCH (CWB)
CWBVER="latest" # Version of CWB to install: 'latest' or 'stable' (WARNING: Currently, only 'latest' is supported).
CWBPLATFORM="linux-64" # Platform to compile CWPweb for. OPTIONS: cygwin, darwin, darwin-64, darwin-brew, darwin-port-core2,
# darwin-universal, linux, linux-64, linux-opteron, mingw-cross, mingw-native, solaris, unix.
# Keep in mind that this script has not been tested on many of these systems.
CWBSITE="standard" # Location for binary installation. 'standard'=/usr/local tree; 'beta-install'=/usr/local/cwb-<VERSION>.
CWBNUKEOLD=0 # Delete previously downloaded CWB files before downloading and installing again? Not normally needed!
# CQPWEB
CQPWEBSW=0 # Install CQPWEB SERVER.
ADMINUSER="YOUR_INFO_HERE" # CQPweb administrator usernames. Separate multiple entries with | .
MYSQL8=0 # Install MySQL v. 8
MYSQLDLURL="https://dev.mysql.com/get/mysql-apt-config_0.8.13-1_all.deb" # URL for downloading the mysql .deb package. You may
# want to manually update this as new versions come out.
DBUSER="cqpweb" # Username for MYSQL database and webuser
DBPWD="cqpweb" # Password for MYSQL database and webuser
CQPMAKENEWDB=0 # Delete existing database and make a new one? (NECESSARY for new installs; normally undesirable otherwise).
CQPWEBNUKEOLD=0 # Delete previously downloaded CQPweb files before downloading and installing again? Not normally needed!
# CQPWEB OPTIONS AND CUSTOMIZATIONS.
# THESE CAN BE RUN INDEPENDENTLY OF THE INSTALLATION OF CQPWEB ITSELF!
IMAGEUPLD=0 # Upload specified image to use as top left/right graphic in CQPweb. Set location and URL below.
IMAGESOURCE1DIR="YOUR_INFO_HERE" # URL of top left/right logo image source file PATH. No trailing slash!
IMAGESOURCE1FILE="YOUR_INFO_HERE" # URL of top left/right logo image source file.
IMAGESOURCE2DIR="YOUR_INFO_HERE" # URL of an additional image source file PATH. No trailing slash!
IMAGESOURCE2FILE="YOUR_INFO_HERE" # URL of an additional image source file.
IMAGETARGET="/var/www/html/cqpweb/css/img" # Destination path of top left/right logo image file.
FAVICONUPLD=0 # Upload favicon.ico to root of website?
FAVICONSOURCE="YOUR_INFO_HERE" # Source URL of favicon.ico.
FAVICONTARGET="/var/www/html/cqpweb/" # Destination directory of favicon.ico.
CREATECQPWEBSCRIPTS=0 # Create a series of useful scripts in ~/bin.
CUSTPGSIGNUP=0 # Customize CQPweb signup page. Users will definitely want to customize this customization.
CUSTPPGTITLES=0 # Customize the titles on CQPweb web pages.
NEWPAGETITLE="Corpora.pro" # New page title. Will be processed by Perl, so escape what needs escaped.
CUSTCQPSYNTUTURL=0 # Change the CQP Syntax tutorial link, for using your own tutorial.
CQPSYNTUTURL="https://www.corpora.pro/userpages/cqp-syntax-tutorial.html" # URL for your own CQP syntax tutorial. Will be processed by Perl, so escape as needed.
CUSTPGMENUGRAPHIC=1 # Replaces the word "Menu" in the T/L cell of most pages with a graphic ('IMAGESOURCE2', above) and optional URL.
MENUURLUSER="YOUR_INFO_HERE" # URL to assign to T/L graphic on user home pages.
MENUURLQUERY="YOUR_INFO_HERE" # URL to assign to T/L graphic on query pages.
MENUURLADMIN="YOUR_INFO_HERE" # URL to assign to T/L graphic on admin pages.
CUSTOMIZEFONTS=0 # Modify CSS files in order to use a user-specified Google web font for most of the interface and/or
# for concordances. To customize one but not the other, set the font to emtpy ("") or "YOUR_INFO_HERE".
MAINFONT="Open Sans" # Name of Google web font for ALMOST EVERYTHING.
CONCFONT="Overpass Mono" # Name of Google web font for CONCORDANCE.
# Check out https://fonts.google.com/ for more web fonts. NOTE: Not all fonts seem to work in all browsers.
# CONFIRMED WORKING FONTS:
# [SANS]: Arimo, Fira Sans, Lato, Noto Sans, Open Sans, PT Sans, Raleway, Roboto, Roboto Condensed
# [MONO-SMALL]: Inconsolata, Ubuntu Mono
# [MONO-MID]: Oxygen Mono, Space Mono, Overpass Mono, Fira Mono, IBM Plex Mono, Source Code Pro
# [MONO-UGLY]test Anonymous Pro, B612 Mono, Cousine, PT Mono
TURNDEBUGON=0 # Set CQPweb to print debug messages.
# CORPORA
CORPDICKENS=0 # Install the Dickens SAMPLE CORPUS. Requires CWB already be installed.
# ADDITIONAL SERVER SOFTWARE AND CONFIGURATION
MAILSW=0 # Install and configure the Postfix mail server.
UPSSW=0 # Install and configure software for APC BackUPS Pro 900 UPS (051d:0002)
DISABLEIPV6=0 # Completely disable ipv6 support in the host OS.
# SECURITY SOFTWARE AND SYSTEM HARDENING
SECURITYSW=0 # Install general security software. Highly recommended for server install.
UFWSW=0 # Install and configure Universal FireWall (UFW). Important for security!
FAIL2BANSW=0 # Install and configure fail2ban. Important for security! But install this last, after you've confirmed everything works.
WHITELISTEDIPS="127.0.0.0/8 10.0.0.0/8 172.16.0.0/12 192.168.0.0/16" # IP addresses to whitelist (never ban) in fail2ban. Separate with space.
APACHESECSW=0 # Install the Apache mod_security and mod_evasive security modules.
SSLSW=0 # Configure server to use SSL (HTTPS) with a certificate from Let's Encrypt.
HARDENMYSQL=0 # Harden the MySQL database. CPQweb must already be installed to use this.
# ADDITIONAL LINGUISTIC SOFTWARE: HEADLESS SERVER OR GUI
FREELINGSW=0 # Install FreeLing tagger.
FREELINGESCLMODS=0 # Modify FreeLing's Chilean Spanish install.
FREELINGNUKEOLD=0 # Delete all downloaded FreeLing files before installing again.
PRAATHEADLESSSW=0 # Install headless Praat phonetic analysis software.
VISIDATASW=0 # Install Visidata, an amazing TUI tool to manipulate and process CSV files.
# ADDITIONAL LINGUISTIC SOFTWARE: OS WITH GUI ONLY
RSTUDIOSW=0 # Install RStudio.
RLINGPKGSW=0 # Install R linguistics and GIS packages.
SPYDERIDESW=0 # Spyder Python IDE.
NLPSW=0 # Install NLP software from Stefan Evert's Comp CorpLing course.
UCSTOOLKITSW=0 # UCS Toolkit collocations software.
PRAATSW=0 # Praat phonetic analysis software (GUI version).
################################################################################
# VARIABLES YOU MUST SET
################################################################################
# MAIL SERVER VARIABLES
# This is mostly independent of CQPweb's mail sending facilites - it's used to alert
# to you system issues like hacking attempts (via fail2ban), failing drives, etc.
SERVERNAME="YOUR_INFO_HERE" # CQPWEB SERVER'S FULL DOMAIN NAME (e.g. 'www.mydomain.com')
SERVERALIAS="YOUR_INFO_HERE" # CQPWEB SERVER'S SHORT DOMAIN NAME (e.g. 'mydomain.com')
ADMINMAILADDR="YOUR_INFO_HERE" # ADMINISTRATOR'S E-MAIL ADDRESS.
OUTMAILSERVER="YOUR_INFO_HERE" # OUTGOING MAIL SERVER URL
MAILSERVERURL="YOUR_INFO_HERE" # GENERAL URL OF MAIL SERVER.
MAILSERVERPWD="YOUR_INFO_HERE" # PASSWORD FOR E-MAIL SERVER. YOU CAN DELETE THIS
# AFTER INSTALLING THE MAIL SERVER, OR YOU CAN LEAVE IT
# EMPTY AND BE PROMPTED FOR A PASSWORD DURING INSTALLATION.
PERSONALMAILADDR="YOUR_INFO_HERE" # YOUR PERSONAL E-MAIL ADDRESS. IF YOU WANT, YOU CAN USE
# THE SAME ADDRESS AS FOR ADMIN, OR VICE VERSA.
# PORTS
# Comment out a port to disable it and automatically close it with UFW.
# If you add a port other than with these variables, make sure to open it in UFW!
SMTPPORT=465
#RSYNCPORT=873
#IMAPSPORT=943
IMAPPORT=993
POP3PORT=995
SSHPORT=YOUR_INFO_HERE # CHOOSE A RANDOM HIGH PORT FOR THIS (10000-60000 IS A GOOD RANGE)
################################################################################
# TIP: ENABLE VMWARE SHARED FOLDERS ON HEADLESS UBUNTU SERVER
# Convenient if you're running the server in a VM.
################################################################################
#
# 1. Create shared folder in VMware GUI
# 2. Inside the VM, run...
# sudo apt install --install-recommends vmfs-tools
# sudo mkdir /mnt/hgfs
# echo ".host:/ /mnt/hgfs fuse.vmhgfs-fuse defaults,allow_other 0 0" | sudo tee -a /etc/fstab
# 3. Reboot the VM
# 4. Link this script to home folder: sudo ln -s /mnt/hgfs/cqptransfer/cqpweb-install.sh /usr/local/bin/cqpweb-install
####################################
# VARIABLES YOU SHOULD *NOT* MODIFY
####################################
DATE="$(date +'%Y/%m/%d')" # Date in YYYY/MM/DD format.
TIME="$(date +'%H:%M:%S')" # Time in HH:MM:SS format.
USER="$(whoami)" # Username of person installing software on local system.
USERGROUPS="$(groups ${USER})" # The groups that the user belongs to.
LOCALHOSTNAME="$(hostname)" # Local system's host name.
#OS="$(cat /etc/lsb-release | grep DISTRIB_ID | sed -r 's/DISTRIB_ID=//')" # Distro name
OS="$(lsb_release -i -s)" # Distro name
RELEASE="$(lsb_release -r -s)"
ETHERNET="$(ip link show | grep '[0-9]: e[a-z0-9]*:' | sed -r 's/^.+ (e[a-z0-9]+):.+$/\1/')" # Ethernet adapter. NOT infallible! PROBABLY FAILS WITH 2+ ADAPTERS.
#ETHERNET=$(ifconfig | grep '^e' | sed -r 's/:.+$//') # Ethernet adapter (older method). NOT infallible! PROBABLY FAILS WITH 2+ ADAPTERS.
EXTERNALIP="$(wget -qO - http://checkip.amazonaws.com)" # Server's external IP.
INTERNALIP="$(ip route get 1.2.3.4 | awk '{print $7}')" # Server's internal IP.
INTERNALIP2="$(ip addr show ${ETHERNET} | grep 'inet ' | awk '{print $2}' | cut -f1 -d'/')" # Server's internal IP (Method 2).
SWDIR="${HOME}/${SHORTSWDIR}" # Full software installation directory.
USERARG="$1"
# MAKE BASIC REQUIRED DIRECTORIES
mkdir -p "${SWDIR}"
################################################################################
# FUNCTION FOR CHANGING CONFIG FILE VALUES
# https://stackoverflow.com/questions/11245144/replace-whole-line-containing-a-string-using-sed
################################################################################
function configLine {
local OLD_LINE_PATTERN=$1; shift
local NEW_LINE=$1; shift
local FILE=$1
local NEW=$(echo "${NEW_LINE}" | sed 's/\//\\\//g')
sudo touch "${FILE}"
sudo sed -i '/'"${OLD_LINE_PATTERN}"'/{s/.*/'"${NEW}"'/;h};${x;/./{x;q100};x}' "${FILE}"
if [[ $? -ne 100 ]] && [[ ${NEW_LINE} != '' ]]; then
echo "${NEW_LINE}" | sudo tee -a "${FILE}"
fi
}
################################################################################
# SET TEXT FORMATTING CODES
################################################################################
CWHT="$(tput setaf 7)" # WHITE
CRED="$(tput setaf 1)" # RED FOR ERROR MESSAGES
CGRN="$(tput setaf 2)" # GREEN
CORG="$(tput setaf 3)" # YELLOW-ORANGE
CMBL="$(tput setaf 4)" # MEDIUM BLUE
CPUR="$(tput setaf 5)" # DARK PURPLE
CLBL="$(tput setaf 6)" # LIGHT BLUE
BLD="$(tput bold)" # BOLD
NBLD="$(tput rmso)" # NO-BOLD
UL="$(tput smul)" # UNDERLINE
NUL="$(tput rmul)" # NO-UNDERLINE
RST="$(tput sgr0)" # RESET ALL FORMATTING
# SET INFORMATIONAL TEXT ABOUT CWB+CQPweb RELEASE BEING INSTALLED
if [[ "$CQPCWBRELEASE" = 0 ]]; then
CQPCWBRELEASETEXT="the ${CORG}most recent revision"
else
CQPCWBRELEASETEXT="${CORG}revision ${CQPCWBRELEASE}"
fi
################################################################################
# SET VARIABLES FOR DIFFERENT TYPES OF INSTALL.
# PROVIDE INFO TO USER IF THEY SPECIFY NO ARGUMENT, TOO MANY ARGUMENTS, OR '-h'
################################################################################
# DEAL WITH VIRTUAL SERVERS FIRST
if [[ "$USERARG" = "vserver" ]]; then
echo "virtual"
USERARG="server"
VIRTUALSRV=1
elif [[ "$USERARG" = "vserverdeluxe" ]]; then
echo "virtual"
USERARG="serverdeluxe"
VIRTUALSRV=1
fi
# NOW PROCESS THE MAIN INSTALL TYPES
if [[ "$USERARG" = "default" ]]; then
# USE VARIABLES AS SET ABOVE.
echo ""
elif [[ "$USERARG" = "vm" ]]; then
# SYSTEM CONFIGURATION
UPGRADEOS=1
CONFIGSHELL=0
CONFIGBASH=1
CONFIGTZ=0
CONFIGCONSOLE=0
CONFIGKEYBOARD=0
CONFIGUBUCLOUD=0
CONFIGHOST=0
# SSH CONFIGURATION
SSHGENNEWKEYS=0
SSHPWDSW=0
SSHKEYSW=0
# MAIN SOFTWARE SETS
NECESSARYSW=1
USEFULSW=1
SERVERSW=0
# CWB+CQPWEB+CORPORA
# CQPCWBRELEASE=0
# CWB
CWB=1
CWBVER="latest"
CWBPLATFORM="linux-64"
CWBSITE="standard"
# CQPWEB
CQPWEBSW=1
CQPMAKENEWDB=1
IMAGEUPLD=0
FAVICONUPLD=0
# CORPORA
CORPDICKENS=1
# ADDITIONAL SYSTEM SOFTWARE
MAILSW=0
SECURITYSW=0
UFWSW=0
UPSSW=0
FAIL2BANSW=0
# ADDITIONAL LINGUISTIC SOFTWARE: HEADLESS SERVER OR GUI
FREELINGSW=0
FREELINGESCLMODS=0
FREELINGNUKEOLD=0
PRAATHEADLESSSW=0
VISIDATASW=0
# ADDITIONAL LINGUISTIC SOFTWARE: OS WITH GUI ONLY
RSTUDIOSW=0
RLINGPKGSW=0
SPYDERIDESW=0
NLPSW=0
UCSTOOLKITSW=0
PRAATSW=0
elif [[ "$USERARG" = "vmdeluxe" ]]; then
echo "vmdeluxe"
# SYSTEM CONFIGURATION
UPGRADEOS=1
CONFIGSHELL=0
CONFIGBASH=1
CONFIGTZ=0
CONFIGCONSOLE=0
CONFIGKEYBOARD=0
CONFIGUBUCLOUD=0
CONFIGHOST=0
# SSH CONFIGURATION
SSHGENNEWKEYS=0
SSHPWDSW=0
SSHKEYSW=0
# MAIN SOFTWARE SETS
NECESSARYSW=1
USEFULSW=1
SERVERSW=0
# CWB+CQPWEB+CORPORA
# CQPCWBRELEASE=0
# CWB
CWB=1
CWBVER="latest"
CWBPLATFORM="linux-64"
CWBSITE="standard"
# CQPWEB
CQPWEBSW=1
CQPMAKENEWDB=1
IMAGEUPLD=0
FAVICONUPLD=0
# CORPORA
CORPDICKENS=1
# ADDITIONAL SYSTEM SOFTWARE
MAILSW=0
SECURITYSW=0
UFWSW=0
UPSSW=0
FAIL2BANSW=0
# ADDITIONAL LINGUISTIC SOFTWARE: HEADLESS SERVER OR GUI
FREELINGSW=0
FREELINGESCLMODS=0
FREELINGNUKEOLD=0
PRAATHEADLESSSW=0
VISIDATASW=0
# ADDITIONAL LINGUISTIC SOFTWARE: OS WITH GUI ONLY
RSTUDIOSW=1
RLINGPKGSW=1
SPYDERIDESW=1
NLPSW=1
UCSTOOLKITSW=1
PRAATSW=1
elif [[ "$USERARG" = "server" ]]; then
echo "server"
# SYSTEM CONFIGURATION
UPGRADEOS=1
CONFIGSHELL=1
CONFIGBASH=1
CONFIGTZ=1
CONFIGCONSOLE=1
CONFIGKEYBOARD=1
CONFIGUBUCLOUD=0
CONFIGHOST=0
# SSH CONFIGURATION
SSHGENNEWKEYS=1
SSHPWDSW=1
SSHKEYSW=0
# MAIN SOFTWARE SETS
NECESSARYSW=1
USEFULSW=1
SERVERSW=1
# CWB+CQPWEB+CORPORA
# CQPCWBRELEASE=0
# CWB
CWB=1
CWBVER="latest"
CWBPLATFORM="linux-64"
CWBSITE="standard"
# CQPWEB
CQPWEBSW=1
CQPMAKENEWDB=1
IMAGEUPLD=0
FAVICONUPLD=0
# CORPORA
CORPDICKENS=1
# ADDITIONAL SYSTEM SOFTWARE
MAILSW=0
SECURITYSW=1
UFWSW=1
UPSSW=0
FAIL2BANSW=0
# ADDITIONAL LINGUISTIC SOFTWARE: HEADLESS SERVER OR GUI
FREELINGSW=0
FREELINGESCLMODS=0
FREELINGNUKEOLD=0
PRAATHEADLESSSW=0
VISIDATASW=0
# ADDITIONAL LINGUISTIC SOFTWARE: OS WITH GUI ONLY
RSTUDIOSW=0
RLINGPKGSW=0
SPYDERIDESW=0
NLPSW=0
UCSTOOLKITSW=0
PRAATSW=0
elif [[ "$USERARG" = "serverdeluxe" ]]; then
echo "serverdeluxe"
# SYSTEM CONFIGURATION
UPGRADEOS=1
CONFIGSHELL=1
CONFIGBASH=1
CONFIGTZ=1
CONFIGCONSOLE=1
CONFIGKEYBOARD=1
CONFIGUBUCLOUD=0
CONFIGHOST=0
# SSH CONFIGURATION
SSHGENNEWKEYS=1
SSHPWDSW=1
SSHKEYSW=0
# MAIN SOFTWARE SETS
NECESSARYSW=1
USEFULSW=1
SERVERSW=1
# CWB+CQPWEB+CORPORA
# CQPCWBRELEASE=0
# CWB
CWB=1
CWBVER="latest"
CWBPLATFORM="linux-64"
CWBSITE="standard"
# CQPWEB
CQPWEBSW=1
CQPMAKENEWDB=1
IMAGEUPLD=0
FAVICONUPLD=0
# CORPORA
CORPDICKENS=1
# ADDITIONAL SYSTEM SOFTWARE
MAILSW=0
SECURITYSW=1
UFWSW=1
UPSSW=0
FAIL2BANSW=1
# ADDITIONAL LINGUISTIC SOFTWARE: HEADLESS SERVER OR GUI
FREELINGSW=0
FREELINGESCLMODS=0
FREELINGNUKEOLD=0
PRAATHEADLESSSW=0
VISIDATASW=0
# ADDITIONAL LINGUISTIC SOFTWARE: OS WITH GUI ONLY
RSTUDIOSW=0
RLINGPKGSW=0
SPYDERIDESW=0
NLPSW=0
UCSTOOLKITSW=0
PRAATSW=0
elif [[ "$USERARG" = "ssh" ]]; then
echo "ssh"
# SYSTEM CONFIGURATION
UPGRADEOS=0
CONFIGSHELL=0
CONFIGBASH=0
CONFIGTZ=0
CONFIGCONSOLE=0
CONFIGKEYBOARD=0
CONFIGUBUCLOUD=0
CONFIGHOST=0
# SSH CONFIGURATION
SSHGENNEWKEYS=0
SSHPWDSW=0
SSHKEYSW=1
# MAIN SOFTWARE SETS
NECESSARYSW=0
USEFULSW=0
SERVERSW=0
# CWB+CQPWEB+CORPORA
# CQPCWBRELEASE=0
# CWB
CWB=0
CWBVER="latest"
CWBPLATFORM="linux-64"
CWBSITE="standard"
# CQPWEB
CQPWEBSW=0
CQPMAKENEWDB=0
IMAGEUPLD=0
FAVICONUPLD=0
# CORPORA
CORPDICKENS=0
# ADDITIONAL SYSTEM SOFTWARE
MAILSW=0
SECURITYSW=0
UFWSW=0
UPSSW=0
FAIL2BANSW=0
# ADDITIONAL LINGUISTIC SOFTWARE: HEADLESS SERVER OR GUI
FREELINGSW=0
FREELINGESCLMODS=0
FREELINGNUKEOLD=0
PRAATHEADLESSSW=0
VISIDATASW=0
# ADDITIONAL LINGUISTIC SOFTWARE: OS WITH GUI ONLY
RSTUDIOSW=0
RLINGPKGSW=0
SPYDERIDESW=0
NLPSW=0
UCSTOOLKITSW=0
PRAATSW=0
else
# PRINT INFORMATION IF -h IS SELECTED OR NO VALID ARGUMENT IS PROVIDED.
echo ""
echo "${CLBL}${BLD}===========================> WELCOME TO CQPWEB-INSTABOX <===========================${RST}"
echo ""
echo "${CWHT}${BLD}This script takes a Ubuntu install (ideally 18.04 LTS) and sets it up with${RST}"
echo "${CWHT}${BLD}Open Corpus Workbench (CWB), CQPweb and other software of your choosing, making${RST}"
echo "${CWHT}${BLD}a customized CQPwebInABox in just a few minutes.${RST}"
echo ""
echo "${CWHT}${BLD}Using CQPWEB-INSTABOX is a two-step process.${RST}"
echo ""
echo "${CWHT}${BLD}First, you must ${CGRN}edit this script${CWHT}, fill in all the fields marked ${CORG}YOUR_INFO_HERE${CWHT} with${RST}"
echo "${CWHT}${BLD}appropriate values, save it, and run it again with the appropriate argument.${RST}"
echo ""
echo "${CWHT}${BLD}Second, you must ${CGRN}run this script with one of the following arguments${CWHT}:${RST}"
echo "${CWHT}${BLD} ${CORG}default${CWHT} : Use the options that are configured in the script. This lets${RST}"
echo "${CWHT}${BLD} you set up a customized install and deploy it.${RST}"
echo "${CWHT}${BLD} ${CORG}vm${CWHT} : Set up a basic CWB and CQPweb install in a virtual machine.${RST}"
echo "${CWHT}${BLD} ${CORG}vmdeluxe${CWHT} : Set up CWB, CQPweb and a series of other linguistics and NLP${RST}"
echo "${CWHT}${BLD} software in a virtual machine.${RST}"
echo "${CWHT}${BLD} ${CORG}server${CWHT} : Set up CWB, CQPweb and basic server software on a bare metal server${RST}"
echo "${CWHT}${BLD} (headless or GUI).${RST}"
echo "${CWHT}${BLD} ${CORG}serverdeluxe${CWHT} : Set up CWB, CQPweb and a suite of server-related software on${RST}"
echo "${CWHT}${BLD} a bare metal server (headless or GUI).${RST}"
echo "${CWHT}${BLD} ${CORG}vserver${CWHT} : Set up CWB, CQPweb and basic server software on a virtual server${RST}"
echo "${CWHT}${BLD} aka VPS (headless or GUI).${RST}"
echo "${CWHT}${BLD} ${CORG}vserverdeluxe${CWHT} : Set up CWB, CQPweb and a suite of server-related software on${RST}"
echo "${CWHT}${BLD} a virtual server aka VPS (headless or GUI).${RST}"
echo "${CWHT}${BLD} ${CORG}ssh${CWHT} : Finish SSH setup after doing a server install.${RST}"
echo "${CWHT}${BLD} ${CORG}-h${CWHT} : See this help message.${RST}"
echo ""
echo "${CWHT}${BLD}Note that the four server options install and configure SSH public key access. This${RST}"
echo "${CWHT}${BLD}requires an additional step -- after the main install, you must upload your public${RST}"
echo "${CWHT}${BLD}SSH key to the server and run this script again, this time with the ${CORG}ssh${CWHT} argument.${RST}"
echo ""
exit
fi
################################################################################
# PRINT WELCOME MESSAGE
################################################################################
echo ""
echo "${CLBL}${BLD}==========> WELCOME TO CQPWEB-INSTABOX <==========${RST}"
echo ""
echo "${CWHT}${BLD} This script installs Open Corpus Workbench (CWB), CQPweb and other software.${RST}"
echo "${CWHT}${BLD} You have selected the ${CGRN}${USERARG}${CWHT} installation option.${RST}"
echo ""
read -r -p "${CORG}${BLD} Do you want to proceed? (y/n) ${RST}" ANSWER
if [[ "$ANSWER" = [yY] || "$ANSWER" = [yY][eE][sS] ]]; then
echo "${CGRN}${BLD}==========> Running CQPWEB-INSTABOX...${RST}"
echo ""
else
echo "${CORG}${BLD}==========> Exiting CQPWEB-INSTABOX.${RST}"
exit
fi
################################################################################
# UDPATE & UPGRADE THE ENTIRE OS INSTALLATION
################################################################################
if [[ "$UPGRADEOS" = 1 ]]; then
echo ""
echo "${CLBL}${BLD}==========> UPDATING & UPGRADING the OS...${RST}"
# UPDATE AND UPGRADE SOFTWARE
sudo apt update -y
sudo apt autoremove -y
sudo apt upgrade -y
# INSTALL SOFTWARE THAT IS REQUIRED FOR EARLY OPERATIONS.
sudo apt install -y --install-recommends apt-show-versions debsums gnupg software-properties-common apt-transport-https dirmngr rng-tools
# FIX RNGTOOLS MISCONFIGURATION ON DEBIAN
if [[ "$OS" = "Debian" ]]; then
echo "HRNGDEVICE=/dev/urandom" | sudo tee -a /etc/default/rng-tools
fi
# PURGE ANY EXISTING MYSQL INSTALL IF MYSQL 8 IS TO BE INSTALLED.
if [[ "$MYSQL8" = 1 ]]; then
sudo apt purge -y mysql*
fi
# CLEAN UP
sudo apt -y autoremove
sudo apt -y autoclean
echo "${CGRN}${BLD}==========> UPDATING & UPGRADING the OS completed (or not needed).${RST}"
echo "${CRED}${BLD} Rebooting now would not be a bad idea.${RST}"
echo ""
else
echo "${CORG}${BLD}==========> Skipping UPDATING & UPGRADING the OS...${RST}"
fi
################################################################################
# CONFIGURE DEFAULT SHELL AS BASH
################################################################################
if [[ "$CONFIGSHELL" = 1 ]]; then
echo ""
echo "${CLBL}${BLD}==========> Reconfiguring DEFAULT SHELL...${RST}"
echo "${CWHT}${BLD} We will now set the DEFAULT SHELL to 'bash' instead of 'dash'. Please enter your${RST}"
echo "${CWHT}${BLD} password if prompted and then answer ${CORG}No${CWHT} to the question that will appear...${RST}"
echo ""
read -r -p "${CORG}${BLD} Press any key to continue (or wait 10 seconds)... ${RST}" -n 1 -t 10 -s
echo ""
sudo dpkg-reconfigure dash
echo "${CGRN}${BLD}==========> DEFAULT SHELL reconfiguration finished.${RST}"
echo ""
else
echo "${CORG}${BLD}==========> Skipping DEFAULT SHELL reconfiguration...${RST}"
fi
################################################################################
# CONFIGURE BASH (~/.bashrc)
################################################################################
if [[ "$CONFIGBASH" = 1 ]]; then
echo ""
echo "${CLBL}${BLD}==========> Configuring BASH...${RST}"
# IF NO BACKUP EXISTS, MAKE ONE
if ! [[ -f "${HOME}/.bashrc.BAK" ]]; then
cp "${HOME}/.bashrc" "${HOME}/.bashrc.BAK"
fi
# REMOVE ORIGINAL FILE
rm "${HOME}/.bashrc"
# WRITE NEW FILE
tee "${HOME}/.bashrc" <<- EOF >/dev/null 2>&1
##### Created by ${SCRIPTNAME} on ${DATE}
# UNALTERED ITEMS FROM ORIGINAL FILE
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# IF NOT RUNNING INTERACTIVELY, DON'T DO ANYTHING
case \$- in
*i*) ;;
*) return;;
esac
# IF SET, THE PATTERN "**" USED IN A PATHNAME EXPANSION CONTEXT WILL
# MATCH ALL FILES AND ZERO OR MORE DIRECTORIES AND SUBDIRECTORIES.
#shopt -s globstar
# MAKE LESS MORE FRIENDLY FOR NON-TEXT INPUT FILES, SEE LESSPIPE(1)
[ -x /usr/bin/lesspipe ] && eval "\$(SHELL=/bin/sh lesspipe)"
# ENABLE COLOR SUPPORT OF LS
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "\$(dircolors -b ~/.dircolors)" || eval "\$(dircolors -b)"
fi
# COLORED GCC WARNINGS AND ERRORS
export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
# LOAD ALIASES FILE IF IT EXISTS
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
# MISC SETTINGS
export LESS='FiX'
export CHEATCOLORS=true
# BAT SETTINGS
export BAT_PAGER="less"
export BAT_THEME="OneHalfDark"
# SAFETY NETS
alias rm='rm -I --preserve-root'
alias chown='chown --preserve-root'
alias chmod='chmod --preserve-root'
alias chgrp='chgrp --preserve-root'
# TERMINAL CONFIGURATION
HISTCONTROL=ignoredups:ignorespace
shopt -s histappend
HISTSIZE=2000
HISTFILESIZE=5000
shopt -s checkwinsize
# COLORIZE MANPAGES
export LESS_TERMCAP_mb=$'\\E[01;31m' # begin blinking
export LESS_TERMCAP_md=$'\\E[01;31m' # begin bold
export LESS_TERMCAP_me=$'\\E[0m' # end mode
export LESS_TERMCAP_so=$'\\E[01;44;33m' # begin standout-mode - info box
export LESS_TERMCAP_se=$'\\E[0m' # end standout-mode
export LESS_TERMCAP_us=$'\\E[01;32m' # begin underline
export LESS_TERMCAP_ue=$'\\E[0m' # end underline
# ALIASES
alias ...='cd ../../../'
alias ..='cd ..'
alias audit='sudo lynis audit system --quick'
alias cd..='cd ..'
alias df='df -h'
alias dm='dmesg -H'
alias egrep='egrep --color=auto -i'
alias fgrep='fgrep --color=auto -i'
alias ga='goaccess /var/log/apache2/access.log'
alias getip='wget -qO - http://wtfismyip.com/text'
alias grep='grep --color=auto -i'
alias j='jobs -l'
alias la='ls -A'
alias lc.='ls -d .*'
alias lc='ls -CF'
alias ll.='ls -ohF -d .*'
alias ll='ls -alF'
alias lla='ls -ohFa'
alias llg='ls -lhFA'
alias lnp='sudo netstat -tulpn'
alias lnpp='sudo nmap -sT -O localhost'
alias loc='lo | column'
alias ls='ls --group-directories-first --color=auto -x'
alias netsrv='sudo netstat -tulpn'
alias ports='netstat -tulanp'
alias sagac='sudo apt autoclean'
alias sagar='sudo apt autoremove'
alias sagi='sudo apt install'
alias sagp='sudo apt purge'
alias sagr='sudo apt remove'
alias sagu='sudo apt update'
alias sagug='sudo apt upgrade'
alias sas='sudo apt search'
alias sn='sudo nano'
alias ssc='sudo systemctl'
alias ugr='sudo apt list --upgradable'
# ALIASES FOR VIEWING LOGFILES
alias alog='lnav /var/log/auth.log'
alias apalog='lnav /var/log/apache2/access.log'
alias apelog='lnav /var/log/apache2/error.log'
alias flog='lnav /var/log/fail2ban.log'
alias klog='lnav /var/log/kern.log'
alias mlog='lnav /var/log/mail.log'
alias mslog='lnav /var/log/apache2/modsec_audit.log'
alias mylog='lnav /var/log/mysql/error.log'
alias plog='lnav /var/log/php_errors.log'
alias slog='lnav /var/log/syslog'
alias ulog='lnav /var/log/ufw.log'
alias upslog='lnav /var/log/apcupsd.events'
# LINGUISTIC THINGS
alias cqp='cqp -eC'
# SOURCE BASHMARKS
source ~/.local/bin/bashmarks.sh
######################
# PROMPT CONFIGURATION
######################
# SET VARIABLE IDENTIFYING SSH USERS
SSH=0
if [[ -n \$SSH_CLIENT ]]; then
SSH=1
fi
# SET VARIABLE IDENTIFYING THE CHROOT YOU WORK IN (USED IN THE PROMPT BELOW)
if [ -z "\$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=\$(cat /etc/debian_chroot)
fi
# SET A FANCY PROMPT (NON-COLOR, UNLESS WE KNOW WE "WANT" COLOR)
case "\$TERM" in
xterm-color) color_prompt=yes;;
esac
force_color_prompt=yes
if [ -n "\$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
color_prompt=yes
else
color_prompt=
fi
fi