-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmkvbox
More file actions
executable file
·2450 lines (2185 loc) · 65.8 KB
/
Copy pathmkvbox
File metadata and controls
executable file
·2450 lines (2185 loc) · 65.8 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
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
#############################################################################
# Configure
# Note: for virtualbox guest additions, mount or insert the
# /usr/share/virtualbox/VBoxGuestAdditions.iso
#############################################################################
CFG_DESKTOP=mate # mate/xfce/lxde/cinnamon/gnome/kde
CFG_IME=ibus # ibus/fcitx
#CFG_VMCN=kvmguest # vbguest/kvmguest
CFG_LOG=install.log # define the log file
CFG_HOSTNAME=mylinux # setup the hostname (archlinux)
CFG_DOMAIN=localdomain # setup the domain name (archlinux)
SSHOST=andy@10.0.2.2
SSPASS=
#############################################################################
# install command line tools
#############################################################################
CFG_CLI="repo cli vim"
#### basic development tools
#CFG_CLI="$CFG_CLI devel"
#### firmware and general development tools
#CFG_CLI="$CFG_CLI devmore"
### ffmpeg & libgd
#CFG_CLI="$CFG_CLI libffmpeg"
####install SDL and freeimage
#CFG_CLI="$CFG_CLI freeimage"
#### python basic and science kit
#CFG_CLI="$CFG_CLI pymore"
#### ftp server and configure
#CFG_CLI="$CFG_CLI vsftpd"
#### setting the bash
CFG_CLI="$CFG_CLI bash"
CFG_CLI="$CFG_CLI archlinux"
#############################################################################
# install X11 GUI tools
#############################################################################
CFG_GUI="xutil"
CFG_GROUP_XUTIL="geary"
#### browers
#CFG_GUI="$CFG_GUI firefox"
#CFG_GUI="$CFG_GUI firefox_qtm"
#CFG_GUI="$CFG_GUI chromium"
#CFG_GUI="$CFG_GUI chrome"
#### Downloader, for example, filezilla, bittorrents
#CFG_GUI="$CFG_GUI downloader"
#### Virtual Machine Hosts
#CFG_GUI="$CFG_GUI virtualbox"
#CFG_GUI="$CFG_GUI kvmhost"
#### Remote Desktop Client
#CFG_GUI="$CFG_GUI remotetty"
#### IM: pidgin
#CFG_GUI="$CFG_GUI pidgin"
#### image and picture tools
#CFG_GUI="$CFG_GUI picture"
CFG_GROUP_PIC="geeqie gthumb imagemagick gimp inkscape"
#### CAD suites
#CFG_GUI="$CFG_GUI cad"
CFG_GROUP_CAD="librecad freecad openscad blender"
####audio player
#CFG_GUI="$CFG_GUI pulsa mp3"
#### video player
#CFG_GUI="$CFG_GUI vlc"
#### GStreamer codec collection
#CFG_GUI="$CFG_GUI gstreamer"
#### office suite
#CFG_GUI="$CFG_GUI office"
#### IME for chinese and japanese
#CFG_GUI="$CFG_GUI ibus"
#CFG_GUI="$CFG_GUI fcitx"
#### chinese fonts and japanese basic fonts. Option: basic full
#CFG_GUI="$CFG_GUI eafont"
CFG_GROUP_EA_FONT="basic"
#CFG_GROUP_EA_FONT="full"
#############################################################################
# Installer with debugger
#############################################################################
CHROOT=
#CHROOT=./tmp
LogAs()
{
echo -e "$@" | tee -a $CFG_LOG
}
LogExec()
{
echo $@ | tee -a $CFG_LOG
if test "x$CHROOT" = "x"; then
eval $@ 2>&1 | tee -a $CFG_LOG
fi
}
LogRunAs()
{
echo $@ | tee -a $CFG_LOG
eval $@ 2>&1 | tee -a $CFG_LOG
}
System()
{
if test -e /etc/centos-release; then
echo CENTOS$(cat /etc/centos-release | cut -d' ' -f4 | cut -d. -f1)
elif $(grep "Ubuntu" /etc/os-release > /dev/null); then
echo "UBUNTU"
elif $(grep "Debian" /etc/os-release > /dev/null); then
echo DEBIAN$(cat /etc/debian_version | cut -d. -f1)
elif test -e /etc/arch-release; then
echo "ARCHLINUX"
else
echo "UNKNOWN"
fi
}
Users()
{
grep '/home/' /etc/passwd | grep bash | cut -f1 -d':'
}
# Installer -g "Package Name", which is group install in CentOs
Installer()
{
local Group="normal"
if test "x$1" = "x-g"; then
Group="group"
shift
fi
if test "x$1" = "x"; then
return
fi
LogAs "\\nINSTALLING $@"
for i in "$@"; do
case $CFG_SYS in
CENTOS8)
if test "x$Group" = "xgroup"; then
LogExec dnf -y groupinstall \"$i\"
else
LogExec dnf -y install "$i"
fi
;;
CENTOS*)
if test "x$Group" = "xgroup"; then
LogExec yum -y groupinstall \"$i\"
else
LogExec yum -y install "$i"
fi
;;
DEBIAN*|UBUNTU)
if test "x$CHROOT" = x; then
apt-get -y install "$i" 2>&1 | tee -a $CFG_LOG
else
apt-get -s -y install "$i" 2>&1 | tee -a $CFG_LOG
fi
;;
ARCHLINUX)
LogExec pacman -S --noconfirm --needed "$i"
;;
esac
done
}
# Used in ArchLinux
# add_users $ADDUSER $ADDPWD
add_users()
{
echo useradd -m -G audio,lp,optical,storage,video,wheel,vboxsf -s /bin/bash "$1" | tee -a $CFG_LOG
if test "x$CHROOT" = "x"; then
useradd -m -G audio,lp,optical,storage,video,wheel,vboxsf -s /bin/bash "$1" | tee -a $CFG_LOG
echo "$1":"$2" | chpasswd
sudo -u "$1" mkdir "/home/$1/bin"
else # debug mode
echo "$1":"$2" | tee -a $CFG_LOG
echo sudo -u "$1" mkdir "/home/$1/bin" | tee -a $CFG_LOG
fi
LogAs "Autologin the first console as the default user [$ADDUSER]."
mkdir -p "$CHROOT/etc/systemd/system/getty@tty1.service.d"
cat > "$CHROOT/etc/systemd/system/getty@tty1.service.d/autologin.conf" << AUTOLOGIN
[Service]
ExecStart=
ExecStart=-/sbin/agetty --autologin $ADDUSER --noclear %I \$TERM
AUTOLOGIN
#auto start X desktop as the default user so no xDM needed
LogAs "Auto-start the X desktop"
cat > $CHROOT/etc/skel/.bash_profile << AUTODESK
if [ -z "\$DISPLAY" ] && [ -n "\$XDG_VTNR" ] && [ "\$XDG_VTNR" -eq 1 ]; then
exec startx
fi
AUTODESK
}
#############################################################################
# Install packages
#############################################################################
Install_Batch_dummy()
{
echo This is a dummy installation for testing only!
}
Repo_Update_CentOS()
{
LogAs "\\nINSTALLING extra and unofficial Repos"
#install extra repos
Installer epel-release
#install Nux Dextop
if test ! -e /etc/yum.repos.d/nux-dextop.repo; then
LogExec rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm
# appending nux-misc repo, for tunctl.
# this repo is default disabled, using it by
# yum --enablerepo=nux-misc install tunctl
cat >> $CHROOT/etc/yum.repos.d/nux-dextop.repo << NUXMISC
[nux-misc]
name=Nux Misc
baseurl=http://li.nux.ro/download/nux/misc/el7/x86_64/
enabled=0
gpgcheck=1
gpgkey=http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro
NUXMISC
fi
#install RPM Fusion
if test ! -e /etc/yum.repos.d/rpmfusion-free-updates.repo; then
LogExec rpm -Uvh https://download1.rpmfusion.org/free/el/rpmfusion-free-release-7.noarch.rpm
fi
if test ! -e /etc/yum.repos.d/rpmfusion-nonfree-updates.repo; then
LogExec rpm -Uvh https://download1.rpmfusion.org/nonfree/el/rpmfusion-nonfree-release-7.noarch.rpm
fi
#install ELRepo
if test "x$1" = "xall"; then
if test ! -e /etc/yum.repos.d/elrepo.repo; then
LogAs "Warning: ELRepo should not be installed ahead of X desktop"
LogExec rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
LogExec rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm
fi
fi
#update and upgrade to the newest releases
LogExec yum -y update
}
Repo_Update_CentOS8()
{
LogAs "\\nINSTALLING extra and unofficial Repos"
#install extra repos
LogExec dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
#install RPM Fusion
LogExec dnf -y install https://download1.rpmfusion.org/free/el/rpmfusion-free-release-8.noarch.rpm
#update and upgrade to the newest releases
LogExec dnf -y update
}
Repo_Update_Debian()
{
local keyring="deb-multimedia-keyring_2016.8.1_all.deb"
grep "main contrib non-free" /etc/apt/sources.list > /dev/null
if test "x$?" != "x0"; then
LogAs "\\nINSTALLING contrib, non-free and unofficial Repos"
LogExec mv -f /etc/apt/sources.list /tmp/sources.list
if test "x$CHROOT" = x; then
sed 's/main/main contrib non-free/' /tmp/sources.list > /etc/apt/sources.list
else
LogAs "sed 's/main/main contrib non-free/' /tmp/sources.list"
fi
LogExec rm -f /tmp/sources.list
fi
# Install Multimedia softwares
grep "deb-multimedia.org" /etc/apt/sources.list > /dev/null
if test "x$?" != "x0"; then
echo -e "\\n# Deb Multimedia for mostly multimedia packages" >> $CHROOT/etc/apt/sources.list
if test "$CFG_SYS" = "DEBIAN7"; then
echo "deb http://www.deb-multimedia.org wheezy main non-free" >> $CHROOT/etc/apt/sources.list
elif test "$CFG_SYS" = "DEBIAN8"; then
echo "deb http://www.deb-multimedia.org jessie main non-free" >> $CHROOT/etc/apt/sources.list
elif test "$CFG_SYS" = "DEBIAN9"; then
echo "deb http://www.deb-multimedia.org stretch main non-free" >> $CHROOT/etc/apt/sources.list
echo "deb http://www.deb-multimedia.org stretch-backports main" >> $CHROOT/etc/apt/sources.list
elif test "$CFG_SYS" = "DEBIAN10"; then
echo "deb http://www.deb-multimedia.org buster main non-free" >> $CHROOT/etc/apt/sources.list
echo "deb http://www.deb-multimedia.org buster-backports main" >> $CHROOT/etc/apt/sources.list
fi
# the backup plan for deb-multimedia keyring
if test -e "./bin/$keyring"; then
LogExec dpkg -i ./bin/$keyring
else
LogExec wget http://www.deb-multimedia.org/pool/main/d/deb-multimedia-keyring/$keyring
if test -e "$keyring"; then
LogExec dpkg -i $keyring
fi
fi
fi
#update and upgrade to the newest releases
LogExec apt-get update
if ! test "x$?" = "x0"; then
exit $?
fi
LogExec apt-get -y upgrade
if ! test "x$?" = "x0"; then
exit $?
fi
}
Repo_Update_Ubuntu()
{
#update and upgrade to the newest releases
LogExec apt-get update
if ! test "x$?" = "x0"; then
exit $?
fi
LogExec apt-get -y upgrade
if ! test "x$?" = "x0"; then
exit $?
fi
}
Repo_Update_Archlinux()
{
Installer -yu
Installer -c
}
Install_Batch_repo()
{
LogAs "\\nINSTALLING Repo of current distribution"
case $CFG_SYS in
CENTOS8) Repo_Update_CentOS8 $@ ;;
CENTOS*) Repo_Update_CentOS $@ ;;
DEBIAN*) Repo_Update_Debian $@ ;;
UBUNTU) Repo_Update_Ubuntu $@ ;;
ARCHLINUX) Repo_Update_Archlinux $@ ;;
*) LogAs "UNKNOWN OS SYSTEM!"
exit 2;;
esac
}
Install_Batch_cli()
{
local VOLUMN="net-tools wget pciutils usbutils cifs-utils arj git p7zip zip unzip \
cpio bc expect ccd2iso mdf2iso"
LogAs "\\nINSTALLING generic CLI tools"
#### ifconfig/lspci/samba/... always needed
case $CFG_SYS in
CENTOS*) VOLUMN="$VOLUMN hexedit attr unrar" ;;
DEBIAN*) VOLUMN="$VOLUMN aptitude openssh-client openssh-server rar steghide stegsnow" ;;
UBUNTU) VOLUMN="$VOLUMN openssh-client openssh-server rar steghide stegsnow" ;;
ARCHLINUX) VOLUMN="$VOLUMN openssh unrar steghide" ;;
esac
for i in $VOLUMN; do
Installer $i
done
}
# OPTIONS:
# filename: output the .vimrc to (can be /dev/stdout)
Install_Batch_vim()
{
local FOUT=$CHROOT/etc/skel/.vimrc
if test "x$1" != "x"; then
FOUT=$1
else
LogAs "\\nINSTALLING VIm"
Installer vim
### Link vi to vim as default
if test -e /usr/bin/vi; then
LogExec rm -f /usr/bin/vi
fi
case $CFG_SYS in
CENTOS*|ARCHLINUX)
if test -e /usr/bin/vim; then
LogExec ln -s /usr/bin/vim /usr/bin/vi
fi
;;
DEBIAN*|UBUNTU)
if test -e /etc/alternatives/vim; then
LogExec ln -s /etc/alternatives/vim /usr/bin/vi
fi
;;
esac
fi
### create a default vim profile
cat > $FOUT << VIMRC
runtime! vimrc_example.vim
filetype indent on
set autoindent
set nobackup
set noundofile
set mouse=
set so=1
VIMRC
}
Install_Batch_devel()
{
LogAs "\\nINSTALLING Basic Development packages (C/C++/GO)"
case $CFG_SYS in
CENTOS*)
Installer -g "Development Tools"
Installer gcc-go
;;
DEBIAN*|UBUNTU)
Installer build-essential
Installer manpages-dev
Installer pkg-config gccgo
;;
ARCHLINUX)
Installer base-devel
Installer gcc-go
;;
esac
# Download and install the lastest GO from its official site
# https://golang.org/dl/
file $(which bash) | grep "ELF 64-bit" > /dev/null
if test "x$?" = "x0"; then
local URL="https://dl.google.com/go/go1.11.4.linux-amd64.tar.gz"
else
local URL="https://dl.google.com/go/go1.11.4.linux-386.tar.gz"
fi
LogExec wget --progress=dot:giga $URL
URL=$(ls go1.11.*)
if test ! -e "$URL"; then
LogAs "ERROR: Go release not downloaded!"
exit
fi
LogExec tar zxf $URL -C /opt
LogExec chown -R root:root /opt/go
LogExec rm -f $URL
}
Install_Batch_libffmpeg()
{
LogAs "\\nINSTALLING ffmpeg and gd development packages"
case $CFG_SYS in
CENTOS*)
Installer ffms2-devel
Installer gd-devel
;;
DEBIAN*|UBUNTU)
Installer libavformat-dev
Installer libswscale-dev
Installer libx11-dev
Installer zlib1g-dev
if test "$CFG_SYS" = "DEBIAN8" || test "$CFG_SYS" = "DEBIAN9"; then
Installer libgd2-dev
else
Installer libgd-dev
fi
;;
ARCHLINUX)
Installer ffmpeg
Installer gd
;;
esac
}
Install_Batch_freeimage()
{
LogAs "\\nINSTALLING freeimage and SDL development packages"
case $CFG_SYS in
CENTOS*)
Installer freeimage-devel
Installer SDL-devel
Installer SDL_gfx-devel
;;
DEBIAN*|UBUNTU)
Installer libfreeimage-dev
Installer libsdl-dev
Installer libsdl-gfx1.2-dev
;;
ARCHLINUX)
Installer sdl2
Installer freeimage
Installer lsb_release
;;
esac
}
Install_Batch_devmore()
{
LogAs "\\nINSTALLING more development packages"
Installer srecord
Installer autoconf
Installer libtool
Installer gdb
}
Install_Batch_pymore()
{
local VOLUMN=""
LogAs "\\nINSTALLING Python related packages"
case $CFG_SYS in
CENTOS*) VOLUMN="$VOLUMN python2-pip python-devel python-virtualenv"
VOLUMN="$VOLUMN python34-pip python34-devel python34-virtualenv"
VOLUMN="$VOLUMN scipy python34-scipy"
;;
DEBIAN*|UBUNTU) VOLUMN="$VOLUMN python-pip python-virtualenv python-sklearn-lib"
VOLUMN="$VOLUMN python-skimage-lib"
VOLUMN="$VOLUMN python3-pip python3-virtualenv python3-sklearn-lib"
;;
ARCHLINUX) VOLUMN="$VOLUMN python-pip python2-pip python-virtualenv python2-virtualenv"
VOLUMN="$VOLUMN python-scipy python2-scipy python-scikit-learn python2-scikit-learn"
VOLUMN="$VOLUMN python-matplotlib python2-matplotlib"
;;
esac
for i in $VOLUMN; do
Installer $i
done
}
#anonymous_enable=NO # Disallow anonymous logins
#local_enable=YES # Enable local users to login
#write_enable=YES # local user to be able to write to a directory
#chroot_local_user=YES # Local users will be ‘chroot jailed’ and they
# # will be denied access to any other part of the server.
Install_Batch_vsftpd()
{
LogAs "\\nINSTALLING and cpnfiguring Vsftpd"
Installer vsftpd
LogExec mv -f /etc/vsftpd/vsftpd.conf /tmp/vsftpd.conf
if test "x$CHROOT" != x; then
LogAs "Configure the /etc/vsftpd/vsftpd.conf file"
else
sed -e 's/^[#]*anonymous_enable=.*/anonymous_enable=NO/1' \
-e 's/^[#]*local_enable=.*/local_enable=YES/1' \
-e 's/^[#]*write_enable=.*/write_enable=YES/1' \
-e 's/^[#]*chroot_local_user=.*/chroot_local_user=YES/1' \
/tmp/vsftpd.conf > /etc/vsftpd/vsftpd.conf
echo -e "\\npasv_enable=Yes\\npasv_max_port=10100\\npasv_min_port=10090\\n" \
>> /etc/vsftpd/vsftpd.conf
fi
LogExec rm -f /tmp/vsftpd.conf
# First restart the service
LogExec systemctl restart vsftpd
# Then set the vsftpd service to start at boot
LogExec systemctl enable vsftpd
# Allow the default FTP port, port 21, through firewalld
LogExec firewall-cmd --permanent --add-port=21/tcp
# make sure it's public/ interfaces: eth0
LogExec firewall-cmd --get-active-zones
LogExec firewall-cmd --permanent --zone=public --add-port=10090-10100/tcp
# reload the firewall
LogExec firewall-cmd --reload
# Update the SELinux policy
LogExec setsebool -P ftpd_full_access 1
LogExec setsebool -P allow_ftpd_anon_write 1
LogExec setsebool -P ftpd_use_passive_mode 1
#getsebool -a | grep ftp
}
Install_Batch_samba()
{
local DEFUSER=$(Users)
LogAs "\\nINSTALLING the SAMBA service."
Installer samba
Installer samba-client
grep mkvbox /etc/samba/smb.conf > /dev/null
if test "x$?" != "x0"; then
LogExec cp /etc/samba/smb.conf /etc/samba/smb.conf_backup
cat > $CHROOT/etc/samba/smb.conf << SMBCFG
# generated by mkvbox
# protocol = SMB2 caused NT_STATUS_INVALID_NETWORK_RESPONSE in Debian 9
# testing:
# service smbd restart
# testparm
# smbclient -L //<HOST_IP_OR_NAME>/<folder_name> -U <user>
[global]
workgroup = WORKGROUP
log file = /var/log/samba/%m.log
passdb backend = tdbsam
# server min protocol = SMB2
protocol = SMB3
# The following configure is for Windows XP
#server max protocol = NT1
#lanman auth = yes
#ntlm auth = yes
# Anonymous Samba sharing
security = user
map to guest = bad user
# Enable usershares
# security = share
usershare path = /var/lib/samba/usershares
usershare max shares = 100
usershare allow guests = yes
usershare owner only = yes
# Disable printer share
load printers = no
printing = bsd
printcap name = /dev/null
disable spoolss = yes
show add printer wizard = no
# Disable NetBIOS/WINS support
disable netbios = yes
dns proxy = no
[homes]
comment = Home Directories
valid users = %S, %D%w%S
# Only share the user's 'Public' folder
path = /home/%S/Public
browseable = Yes
read only = No
inherit acls = Yes
[public]
comment = Public Anonymous Access
path = /var/samba/
browsable =yes
writable = yes
guest ok = yes
create mask = 0660
directory mask = 0775
SMBCFG
fi
grep sambashare /etc/group > /dev/null
if test "x$?" != "x0"; then
LogExec groupadd -r sambashare
if test "x$DEFUSER" != "x"; then
LogExec /sbin/usermod -a -G sambashare $DEFUSER
fi
fi
if test ! -d /var/samba; then
LogExec mkdir -p /var/samba
LogExec chmod 1777 /var/samba
fi
if test ! -d /var/lib/samba/usershares; then
LogExec mkdir -p /var/lib/samba/usershares
LogExec chown root:sambashare /var/lib/samba/usershares
LogExec chmod 1770 /var/lib/samba/usershares
fi
for i in $DEFUSER; do
pdbedit -u $DEFUSER > /dev/null
if test "x$?" != "x0"; then
LogAs "Adding the Samba User: $i"
LogExec smbpasswd -a "$i"
fi
done
# start the service
case $CFG_SYS in
CENTOS*|ARCHLINUX)
LogExec chcon -t samba_share_t /var/samba
LogExec systemctl enable smb.service
LogExec systemctl enable nmb.service
LogExec systemctl restart smb.service
LogExec systemctl restart nmb.service
# SELinux settings
LogExec setsebool -P samba_domain_controller on
LogExec setsebool -P samba_enable_home_dirs on
;;
DEBIAN*|UBUNTU)
Installer smbnetfs
LogExec systemctl enable smbd
LogExec systemctl restart smbd
;;
esac
# create firewall rule
systemctl status firewalld > /dev/null
if test "x$?" = "x0"; then
LogExec firewall-cmd --permanent --zone=public --add-service=samba
LogExec firewall-cmd --reload
fi
}
# OPTIONS:
# filename: output the .bashrc to (can be /dev/stdout)
Install_Batch_bash()
{
local FOUT=$CHROOT/etc/skel/.bashrc
if test "x$1" != "x"; then
FOUT=$1
fi
LogAs "\\nINSTALLING the $FOUT file."
if $(grep "bcc EXPRESSIONS" $FOUT > /dev/null); then
return
fi
cat >> $FOUT << BASHRC
# If not running interactively, don't do anything
[[ \$- != *i* ]] && return
ulimit -c unlimited
PS1='\u:\w\\$ '
if ! \$(echo \$PATH | grep '/home/' > /dev/null); then
PATH="\$PATH:\$HOME/bin:."
fi
# replace expr with the bc command line express
bcc()
{
if test "x\$@" = "x"; then
echo A quick call to GNU bc, i.e., bcc EXPRESSIONS
else
echo \$@ | tr -d ',' | bc -l
fi
}
path()
{
for i in \$(echo \$PATH | tr ':' '\\n'); do
echo " \$i"
done
}
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto'
alias l.='ls -d .* --color=auto'
alias ls='ls --color=auto'
alias ll='ls -lh --color=auto'
alias cp='cp -i'
alias mv='mv -i'
BASHRC
case $CFG_SYS in
CENTOS*)
echo "alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'" >> $FOUT
;;
DEBIAN*|UBUNTU)
;;
ARCHLINUX)
;;
esac
echo "" >> $FOUT
}
Install_Batch_archlinux()
{
if test "x$CFG_SYS" != "xARCHLINUX"; then
return
fi
if test ! -L /etc/localtime; then
LogAs "\\nINSTALLING local time to Sydney, Australia"
LogExec ln -sf /usr/share/zoneinfo/Australia/Sydney /etc/localtime
LogExec hwclock --systohc
LogAs "\\nINSTALLING Network Time Control"
LogExec timedatectl set-ntp true
fi
if test ! -e /etc/locale.conf; then
LogAs "\\nINSTALLING locale: Chinese included"
cat >> /etc/locale.gen << LOCALE
en_US.UTF8 UTF-8
zh_CN.UTF8 UTF-8
zh_CN.GBK GBK
zh_CN.GB2312 GB2312
zh_CN.GB18030 GB18030
LOCALE
LogExec locale-gen
LogExec echo "LANG=en_US.UTF-8" >> /etc/locale.conf
fi
if test ! -e /etc/hostname; then
LogAs "\\nINSTALLING hostname: $CFG_HOSTNAME.$CFG_DOMAIN"
echo "$CFG_HOSTNAME" > /etc/hostname
echo "127.0.0.1 $CFG_HOSTNAME.$CFG_DOMAIN $CFG_HOSTNAME" >> /etc/hosts
fi
if test ! -e /etc/sudoer; then
LogAs "\\nINSTALLING sudo"
Installer sudo
echo "%wheel ALL=(ALL) ALL" >> /etc/sudoer
fi
LogAs "\\nINSTALLING the coredump in sysctl"
LogExec sysctl -w kernel.core_pattern="core"
}
# OPTIONS:
# -s: single user only
Install_Batch_skel()
{
local PROFILE="/etc/skel/.bashrc /etc/skel/.vimrc"
# installing the script to current user first
LogExec cp -f $PROFILE ~
if test $(id -u) != 0 || test "x$1" = "x-s"; then
# if user is not root, or specified the single user only flag
LogAs "\\nINSTALLING profiles from /etc/skel"
return
fi
# only root can install the profiles to all users
LogAs "\\nINSTALLING profiles from /etc/skel to all users"
Installer sudo
for i in $(Users); do
LogExec sudo -u $i cp -f $PROFILE /home/$i
done
}
Install_Batch_group()
{
local DEFUSER=$(Users)
if test "x$DEFUSER" = "x"; then
return
fi
# Add user to group to access: the usb serial port
LogAs "\\nINSTALLING default user groups"
case $CFG_SYS in
CENTOS*) LogExec usermod -a -G audio,video,wheel,cdrom,dialout $DEFUSER ;;
DEBIAN*) LogExec usermod -a -G audio,video,cdrom,dialout,sudo,games $DEFUSER ;;
UBUNTU) LogExec usermod -a -G audio,video,dialout $DEFUSER ;;
ARCHLINUX) LogExec usermod -a -G audio,video,wheel,optical,storage,uucp $DEFUSER ;;
esac
}
Install_Batch_eth0()
{
# Note that in the document
# https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames
# whilst those three options only the last one, kernel command line, works (debian 9)
LogAs "\\nINSTALLING traditional network interface eth0"
ip link | grep eth0 > /dev/null
if test "x$?" = "x0"; then
LogAs "Traditional 'eth0' interface is found."
return
fi
grep "GRUB_CMDLINE_LINUX=\"net.ifnames=0" /etc/default/grub
if test "x$?" != "x0"; then
LogExec mv -f /etc/default/grub /tmp/grub
if test "x$CHROOT" != "x"; then
LogAs "Disabling the Predictable Network Interface Names"
else
sed -e 's/^[#]*GRUB_CMDLINE_LINUX=\"/GRUB_CMDLINE_LINUX=\"net.ifnames=0 /1' \
/tmp/grub > /etc/default/grub
LogExec grub-mkconfig -o /boot/grub/grub.cfg
fi
LogExec rm -f /tmp/grub
fi
case $CFG_SYS in
CENTOS*)
if test -e /etc/sysconfig/network-scripts/ifcfg-eth0; then
LogAs "Interface 'eth0' is already configured."
elif test "x$CHROOT" != "x"; then
LogAs "Restore eth0 interface in $CFG_SYS"
else
sed -e 's/NAME=.*/NAME="eth0"/1' \
-e 's/DEVICE=.*/DEVICE="eth0"/1' \
/etc/sysconfig/network-scripts/ifcfg-en* > /etc/sysconfig/network-scripts/ifcfg-eth0
fi
;;
DEBIAN*)
LogExec mv -f /etc/network/interfaces /tmp/interfaces
if test "x$CHROOT" != "x"; then
LogAs "Restore eth0 interface in $CFG_SYS"
else
sed -e 's/allow-hotplug.*/allow-hotplug eth0/1' \
-e 's/iface en.*/iface eth0 inet dhcp/1' \
/tmp/interfaces > /etc/network/interfaces
fi
LogExec rm -f /tmp/interfaces
;;
UBUNTU)
for i in $(grep -l ethernets /etc/netplan/*); do
LogExec mv -f $i /tmp/interface
if test "x$CHROOT" != "x"; then
LogAs "Restore eth0 interface in $CFG_SYS"
else
sed 's/ en.*/ eth0/1' /tmp/interface > $i
fi
LogExec rm -f /tmp/interface
done
;;
ARCHLINUX)
LogExec mv -f /etc/netctl/ethernet-dhcp /tmp/interfaces
if test "x$CHROOT" != "x"; then
LogAs "Restore eth0 interface in $CFG_SYS"
else
sed 's/Interface=.*/Interface=eth0/1' /tmp/interfaces > /etc/netctl/ethernet-dhcp
netctl reenable ethernet-dhcp
fi
LogExec rm -f /tmp/interfaces
;;
esac
}
#############################################################################
# Install X applications
#############################################################################
Install_LightDM_Arch()
{
# install and config the lightdm in Archlinux
Installer lightdm
Installer lightdm-gtk-greeter
LogExec mv -f /etc/lightdm/lightdm.conf /tmp/lightdm.conf
if test "x$CHROOT" = x; then
sed 's/#greeter-session=example-gtk-gnome/greeter-session=lightdm-gtk-greeter/' \
/tmp/lightdm.conf > /etc/lightdm/lightdm.conf
else
LogAs "sed 's/#greeter-session=example-gtk-gnome/greeter-session=lightdm-gtk-greeter/' ..."
fi
LogExec rm -f /tmp/lightdm.conf
LogExec systemctl enable lightdm.service
}
Install_Desktop_Mate()
{
case $CFG_SYS in
CENTOS*)
#Installer --enablerepo=epel-testing atril atril-caja
LogExec yum -y --enablerepo=epel-testing install atril atril-caja
Installer -g "MATE Desktop"
Installer caja-share
;;
DEBIAN*)
Installer mate-desktop-environment-extras
Installer lightdm
;;
UBUNTU)
Installer lightdm
Installer ubuntu-mate-desktop
;;
ARCHLINUX)
Installer mate
Installer mate-extra
Install_LightDM_Arch
echo "exec mate-session" > $CHROOT/etc/skel/.xinitrc
esac
}
Install_Desktop_Xfce()
{
case $CFG_SYS in
CENTOS*)
Installer -g "Xfce"
Installer mousepad
;;
DEBIAN*|UBUNTU)
Installer xfce4
Installer xfce4-goodies
Installer thunar-archive-plugin
Installer lightdm
;;
ARCHLINUX)
Installer xfce4