-
Notifications
You must be signed in to change notification settings - Fork 1
/
actwelve.sh
executable file
·1085 lines (900 loc) · 36.6 KB
/
actwelve.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
# ---------------------------------------------------------------------------
# actwelve - Library functions for various uses
# Copyright 2015, Andrew Innes <andrew.c12@gmail.com>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License at <http://www.gnu.org/licenses/> for
# more details.
# Usage: new_script [-h|--help] [-q|--quiet] [-s|--root] [script]
# Revision history:
# 2015-04-12 Created
# ---------------------------------------------------------------------------
function f_actwelve_chooseDebianRelease {
local __resultvar=$1
local DIALOG=${DIALOG=dialog}
local tempfile=`tempfile 2>/dev/null` || exit 1
trap "rm -f $tempfile" 0 1 2 5 15
# Debian release selection
$DIALOG --clear --title "Debian Release" \
--menu "Choose the Debian Release:" 20 51 4 \
"jessie" "Debian 8 Jessie" \
"wheezy" "Debian 7 Wheezy" 2> $tempfile
retval=$?
local myresult=`cat $tempfile`
if [[ "$__resultvar" ]]; then
eval $__resultvar="'$myresult'"
else
echo "$myresult"
fi
return $retval
}
function f_actwelve_chooseLxcBackingStore {
local __resultvar=$1
local DIALOG=${DIALOG=dialog}
local tempfile=`tempfile 2>/dev/null` || exit 1
trap "rm -f $tempfile" 0 1 2 5 15
# Backing store selection
$DIALOG --clear --title "Backing Store" \
--menu "Choose the Backing store:" 20 51 4 \
"dir" "A directory" \
"none" "A directory" \
"loop" "A file backed loop device" 2> $tempfile
retval=$?
local myresult=`cat $tempfile`
if [[ "$__resultvar" ]]; then
eval $__resultvar="'$myresult'"
else
echo "$myresult"
fi
return $retval
}
function f_actwelve_chooseLxcName {
local __resultvar=$1
local DIALOG=${DIALOG=dialog}
local tempfile=`tempfile 2>/dev/null` || exit 1
trap "rm -f $tempfile" 0 1 2 5 15
# Container name selection
$DIALOG --title "Container Name" --clear \
--inputbox "Choose a name for your container:" 16 51 2> $tempfile
retval=$?
local myresult=`cat $tempfile`
if [[ "$__resultvar" ]]; then
eval $__resultvar="'$myresult'"
else
echo "$myresult"
fi
return $retval
}
function f_actwelve_inputIpAddress {
local __resultvar=$1
local DIALOG=${DIALOG=dialog}
local tempfile=`tempfile 2>/dev/null` || exit 1
trap "rm -f $tempfile" 0 1 2 5 15
# Input IP address
$DIALOG --title "IP address" --clear \
--inputbox "Enter IP address:" 16 51 2> $tempfile
retval=$?
local myresult=`cat $tempfile`
if [[ "$__resultvar" ]]; then
eval $__resultvar="'$myresult'"
else
echo "$myresult"
fi
return $retval
}
function f_actwelve_chooseRamSizeMB {
local __resultvar=$1
local DIALOG=${DIALOG=dialog}
local tempfile=`tempfile 2>/dev/null` || exit 1
trap "rm -f $tempfile" 0 1 2 5 15
# Debian release selection
$DIALOG --clear --title "RAM Size" \
--menu "Choose the RAM Size:" 20 51 16 \
"1" "1MB" \
"2" "2MB" \
"4" "4MB" \
"8" "8MB" \
"16" "16MB" \
"32" "32MB" \
"64" "64MB" \
"128" "128MB" \
"256" "256MB" \
"512" "512MB" \
"1024" "1024MB" \
"2048" "2048MB" \
"4096" "4096MB" \
"8192" "8192MB" \
"16384" "16384MB" \
"32768" "32768MB" 2> $tempfile
retval=$?
local myresult=`cat $tempfile`
if [[ "$__resultvar" ]]; then
eval $__resultvar="'$myresult'"
else
echo "$myresult"
fi
return $retval
}
return 0
#!/bin/sh
mkdir /tmp/di$debarch
cd /tmp/di$debarch
wget -c ftp://ftp.debian.org/debian/dists/wheezy/main/installer-$debarch/current/images/netboot/netboot.tar.gz
tar -xvf netboot.tar.gz
mkdir -p $tftppath/debian-installer/
mv debian-installer/$debarch $tftppath/debian-installer/.
cat >> $pxelinuxmenu << EOF
MENU BEGIN DI$debarch
MENU LABEL Install debian $debarch
MENU TITLE Install debian $debarch
LABEL Back
MENU EXIT
MENU LABEL Back
MENU INCLUDE debian-installer/$debarch/boot-screens/menu.cfg
MENU END
EOF#!/bin/sh
cat >> $pxelinuxmenu << EOF
LABEL preseedDI$debarch
MENU LABEL Install debian $debarch preseed
kernel debian-installer/$debarch/linux
append vga=normal initrd=debian-installer/$debarch/initrd.gz auto=true interface=auto netcfg/dhcp_timeout=60 netcfg/choose_interface=auto priority=critical preseed/url=tftp://$pxeip/debian-installer/preseed.cfg DEBCONF_DEBUG=5
# IPAPPEND 2
EOF#!/bin/sh
cd /tmp
wget -c http://download.plop.at/files/bootmngr/plpbt-5.0.15-test.zip
unzip plpbt-5.0.15-test.zip
mv plpbt-5.0.15-test $tftppath/images/plop
cat >> $pxelinuxmenu << EOF
MENU BEGIN Plop
MENU LABEL Plop
MENU TITLE Plop boot loader
LABEL Back
MENU EXIT
MENU LABEL Back
LABEL Plop Live
kernel images/plop/plpbt.bin
MENU LABEL Plop
TEXT HELP
Run Plop
ENDTEXT
LABEL Plop Install
kernel images/plop/install/plpinstc.com
MENU LABEL Install Plop
TEXT HELP
Run Plop Install
ENDTEXT
MENU END
EOF#!/bin/sh
#13:30 < Riviera> wingman2: needs error handling; you don't check whether apt-get, cd, cp, wget, unzip, mkdir, etc. were successful,
# you should quote your expansions ("/msg greybot umq") and, if it doesn't go against your idea of aesthetics, you
# should indent your code to improve its readability
#13:34 <greybot> "Double quote" _every_ expansion, and anything that could contain a special character, eg. "$var", "$@",
# "${array[@]}", "$(command)". Use 'single quotes' to make something literal, eg. 'Costs $5 USD'. See
# <http://mywiki.wooledge.org/Quotes>, <http://mywiki.wooledge.org/Arguments> and
# <http://wiki.bash-hackers.org/syntax/words>.
export PXEIP=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
DHCPBROADCAST=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $4}')
DHCPDCONF="/etc/dhcp/dhcpd.conf"
#export PXEIP="10.0.0.137"
export TFTPPATH="/srv/tftp"
export PXELINUXMENU="$TFTPPATH/pxelinux.cfg/default"
SYSLINUXPATH="/usr/lib/syslinux"
DHCPSUBNET="10.0.0.0"
DHCPNETMASK="255.255.255.0"
DHCPLEASESTART="10.0.0.180"
DHCPLEASESTOP="10.0.0.200"
#DHCPBROADCAST="10.0.0.255"
DHCPROUTER="10.0.0.138"
DHCPDNS="10.0.0.138"
#Enter the Mac address of the computers you want to boot
#or comment out ignore unknown-clients; below
PXEMAC1="08:00:27:F4:1E:9C"
PXEMAC2="08:00:27:F4:1E:9C"
PXEMAC3="08:00:27:F4:1E:9C"
PXEMAC4="08:00:27:F4:1E:9C"
#URL='http://login:password@example.com/one/more/dir/file.exe?a=sth&b=sth'
#AFTER_SLASH=${URL##*/}
#echo "/one/more/dir/${AFTER_SLASH%%\?*}"
#http://downloads.sourceforge.net/project/clonezilla/clonezilla_live_stable/2.2.1-25/clonezilla-live-2.2.1-25-i686-pae.zip
#FILE=/home/user/src/prog.c
#echo ${FILE#/*/} # ==> user/src/prog.c
#echo ${FILE##/*/} # ==> prog.c
#echo ${FILE%/*} # ==> /home/user/src
#echo ${FILE%%/*} # ==> nil
#echo ${FILE%.c} # ==> /home/user/src/prog
#done test
#fix this with regex
CZPAEURL="http://downloads.sourceforge.net/project/clonezilla/clonezilla_live_stable/2.2.1-25/clonezilla-live-2.2.1-25-i686-pae.zip"
INSTALLCLONEZILLA=0
INSTALLPLOP=0
INSTALLDEBIANAMD64=1
INSTALLDEBIANI386=0
INSTALLDEBIANPRESEED=1
# http://linuxcommand.org/wss0150.php
#PROGNAME=$(basename $0)
#function error_exit
#{
# echo "${PROGNAME}: ${1:-"Unknown Error"}" 1>&2
# exit 1
#}
# Example call of the error_exit function. Note the inclusion
# of the LINENO environment variable. It contains the current
# line number.
# error handling
# Simplest of all
#echo "Example of error with line number and message"
#cd $some_directory || error_exit "$LINENO: Cannot change directory! Aborting"
#rm *
installdebian(){
mkdir /tmp/di${DEBARCH}
cd /tmp/di${DEBARCH}
wget -c ftp://ftp.debian.org/debian/dists/wheezy/main/installer-${DEBARCH}/current/images/netboot/netboot.tar.gz
tar -xvf netboot.tar.gz
mkdir -p $TFTPPATH/debian-installer/
mv debian-installer/${DEBARCH} $TFTPPATH/debian-installer/.
cat >> $PXELINUXMENU << EOF
MENU BEGIN DI${DEBARCH}
MENU LABEL Install debian ${DEBARCH}
MENU TITLE Install debian ${DEBARCH}
LABEL Back
MENU EXIT
MENU LABEL Back
MENU INCLUDE debian-installer/${DEBARCH}/boot-screens/menu.cfg
MENU END
EOF
}
installdebianpreseed(){
cat >> $PXELINUXMENU << EOF
LABEL preseedDI${DEBARCH}
MENU LABEL Install debian ${DEBARCH} preseed
kernel debian-installer/${DEBARCH}/linux
append vga=normal initrd=debian-installer/${DEBARCH}/initrd.gz auto=true interface=auto netcfg/dhcp_timeout=60 netcfg/choose_interface=auto priority=critical preseed/url=tftp://$PXEIP/debian-installer/preseed.cfg DEBCONF_DEBUG=5
EOF
}
apt-get install isc-dhcp-server tftpd-hpa
cat > $DHCPDCONF << EOF
default-lease-time 600;
max-lease-time 7200;
allow booting;
#ignore unknown-clients;
subnet $DHCPSUBNET netmask $DHCPNETMASK {
range $DHCPLEASESTART $DHCPLEASESTOP;
option broadcast-address $DHCPBROADCAST;
option routers $DHCPROUTER;
option domain-name-servers $DHCPDNS;
next-server $PXEIP;
}
#chainloading
if exists user-class and option user-class = "gPXE" {
filename "pxelinux.0";
} else {
if substring(option vendor-class-identifier, 0, 9) = "PXEClient" {
filename "gpxelinux.0";
}
}
#Find out if this works
#if substring(option vendor-class-identifier, 0, 9) = "PXEClient" {filename "gpxelinux.0";}
#if exists user-class and option user-class = "gPXE" {filename "pxelinux.0";}
host 1 { hardware ethernet $PXEMAC1; }
host 2 { hardware ethernet $PXEMAC2; }
host 3 { hardware ethernet $PXEMAC3; }
host 4 { hardware ethernet $PXEMAC4; }
EOF
/etc/init.d/isc-dhcp-server restart
#In this section we set up a menu to load and boot files from the network
#Files to boot
mkdir $TFTPPATH/
mkdir $TFTPPATH/images
mkdir $TFTPPATH/pxelinux.cfg
#Copy syslinux files
apt-get install syslinux
cp $SYSLINUXPATH/pxelinux.0 $TFTPPATH/
cp $SYSLINUXPATH/gpxelinux.0 $TFTPPATH/
cp $SYSLINUXPATH/menu.c32 $TFTPPATH/
cp $SYSLINUXPATH/vesamenu.c32 $TFTPPATH/
cp $SYSLINUXPATH/reboot.c32 $TFTPPATH/
cp $SYSLINUXPATH/chain.c32 $TFTPPATH/
cp $SYSLINUXPATH/memdisk $TFTPPATH/
cat > $PXELINUXMENU << EOF
ui menu.c32
menu title Utilities
EOF
##############################################################################################################
if [ "$INSTALLCLONEZILLA" -eq 1 ]
then
#Extract the latest version
mkdir /tmp/clonezilla
cd /tmp
wget -c $CZPAEURL #http://downloads.sourceforge.net/project/clonezilla/clonezilla_live_stable/2.2.1-25/clonezilla-live-2.2.1-25-i686-pae.zip
cd /tmp/clonezilla
unzip ../${CZPAEURL##*/} #clonezilla-live-2.2.1-25-i686-pae.zip
cd ..
mv clonezilla $TFTPPATH/images/clonezilla
cat >> $PXELINUXMENU << EOF
label clonezilla
menu label Clonezilla
kernel images/clonezilla/live/vmlinuz
append boot=live username=user config noswap edd=on nomodeset noprompt locales= keyboard-layouts= ocs_live_run="ocs-live-general" ocs_live_extra_param="" ocs_live_batch=no vga=788 nosplash fetch=tftp://$PXEIP/images/clonezilla/live/filesystem.squashfs i915.blacklist=yes radeonhd.blacklist=yes nouveau.blacklist=yes vmwgfx.enable_fbdev=no
initrd images/clonezilla/live/initrd.img
EOF
fi
#################################################################################################################
if [ "$INSTALLPLOP" -eq 1 ]
then
cd /tmp
wget -c http://download.plop.at/files/bootmngr/plpbt-5.0.15-test.zip
unzip plpbt-5.0.15-test.zip
mv plpbt-5.0.15-test $TFTPPATH/images/plop
cat >> $PXELINUXMENU << EOF
MENU BEGIN Plop
MENU LABEL Plop
MENU TITLE Plop boot loader
LABEL Back
MENU EXIT
MENU LABEL Back
LABEL Plop Live
kernel images/plop/plpbt.bin
MENU LABEL Plop
TEXT HELP
Run Plop
ENDTEXT
LABEL Plop Install
kernel images/plop/install/plpinstc.com
MENU LABEL Install Plop
TEXT HELP
Run Plop Install
ENDTEXT
MENU END
EOF
fi
##############################################################################################################
if [ "$INSTALLDEBIANAMD64" -eq 1 ]
then
export DEBARCH="amd64"
installdebian
if [ "$INSTALLDEBIANPRESEED" -eq 1 ]
then
installdebianpreseed
fi
fi
##############################################################################################################
if [ "$INSTALLDEBIANI386" -eq 1 ]
then
export DEBARCH="i386"
installdebian
if [ "$INSTALLDEBIANPRESEED" -eq 1 ]
then
installdebianpreseed
fi
fi
##############################################################################################################
#cd /tmp
#wget -c http://mirrors.xbmc.org/releases/XBMCbuntu/xbmcbuntu-13.0~gotham_amd64.iso
#mkdir /mnt/iso
#mount -o loop xbmcbuntu-13.0~gotham_amd64.iso /mnt/iso
#mkdir /tmp/xbmcbuntu-13.0~gotham_amd64
#cp -R /mnt/iso/* /tmp/xbmcbuntu-13.0~gotham_amd64
#umount /mnt/iso
#mv xbmcbuntu-13.0~gotham_amd64 /srv/tftp/images/.
#apt-get install nfs-kernel-server
# /etc/exports
#
# /srv/tftp/images/xbmcbuntu-13.0~gotham_amd64 10.0.0.0/255.255.255.0(async,no_root_squash,no_subtree_check,ro)
#
#service nfs-kernel-server restart
#
#label xbmc
# menu label ^Try XBMCbuntu without installing
# kernel images/xbmcbuntu-13.0~gotham_amd64/casper/vmlinuz
# append boot=casper netboot=nfs nfsroot=10.0.0.191:/srv/tftp/images/xbmcbuntu-13.0~gotham_amd64/ initrd=images/xbmcbuntu-13.0~gotham_amd64/casper/initrd.lz --
# label bootlocal
# menu label ^Boot Point of Sale
# menu default
# localboot 0
# timeout 80
# TOTALTIMEOUT 9000
/etc/init.d/tftpd-hpa restart
#!/bin/bash
#TODO:
#Actually set up reverse SSH tunnel + private sshkey
#rev16 sshkey
#rev15 hostname
#rev13 onthepull
#rev11 yes after omv extra package
#rev10 autossh service
#rev9 sysctl
#rev8 autossh service + Reducing the number of worker threads on the web server
#rev7 omv extras
#rev6 Created symbolic link because boot is on another partition hence there is no boot folder
#rev5 fix fstab
#rev4 use case so that part2 is the same script
#rev1 quote EOF so the heredoc is treated literally
#DRIVE="/dev/sda"
#BOOT="/dev/sda1"
#ROOT="/dev/sda2"
DRIVE="/dev/mmcblk0"
BOOT="/dev/mmcblk0p1"
ROOT="/dev/mmcblk0p2"
TARGET="/target"
function part1 {
fdisk $DRIVE <<EOF
o
n
p
1
+64M
n
p
2
w
EOF
mkfs.ext2 $BOOT
mkfs.f2fs $ROOT
mkdir $TARGET
mount $ROOT $TARGET
mkdir $TARGET/boot
mount $BOOT $TARGET/boot
cd $TARGET
wget --no-check-certificate https://www.dropbox.com/s/uav4oc6oibmo5mb/Debian-3.17.0-kirkwood-tld-1-rootfs-bodhi.tar.bz2?dl=1
tar -xvf Debian-3.17.0-kirkwood-tld-1-rootfs-bodhi.tar.bz2?dl=1
mount -t proc proc proc/
mount -t sysfs sys sys/
mount -o bind /dev dev/
cp /etc/resolv.conf etc/resolv.conf
cp /home/andrew/mkomv.sh mkomv.sh
chmod +x mkomv.sh
chroot ./ /mkomv.sh part2
exit 0
}
function part2 {
cd /boot
cp -a zImage-3.17.0-kirkwood-tld-1 zImage.fdt
cat dts/kirkwood-pogoplug_v4.dtb >> zImage.fdt
mkimage -A arm -O linux -T kernel -C none -a 0x00008000 -e 0x00008000 -n Linux-3.17.0-kirkwood-tld-1 -d /boot/zImage.fdt /boot/uImage
mkimage -A arm -O linux -T ramdisk -C gzip -a 0x00000000 -e 0x00000000 -n initramfs-3.17.0-kirkwood-tld-1 -d /boot/initrd.img-3.17.0-kirkwood-tld-1 /boot/uInitrd
passwd
cd /tmp
wget http://ftp.us.debian.org/debian/pool/main/f/f2fs-tools/f2fs-tools_1.4.0-2_armel.deb
#apt-get install f2fs-tools
dpkg -i f2fs-tools_1.4.0-2_armel.deb
#nano /etc/fstab
#sed -i "s/STRING_TO_REPLACE/STRING_TO_REPLACE_IT/g" /etc/fstab
sed -i "s/ext3/f2fs/g" /etc/fstab
sed -i "s/noatime,errors=remount-ro 0 1/noatime,nodiratime,discard 0 0/g" /etc/fstab
#noatime,nodiratime,discard
#noatime,errors=remount-ro 0 1
#sed -i "s/ext3/f2fs/g" /etc/fstab
cat >> /etc/sysctl.conf <<EOF
vm.laptop_mode=5
vm.dirty_writeback_centisecs=1500
vm.dirty_expire_centisecs=1500
# defaults shown, suggested values of 10 and 1
vm.dirty_ratio = 50
vm.dirty_background_ratio = 10
EOF
cat > /etc/apt/sources.list << EOF
deb http://ftp.us.debian.org/debian/ wheezy main contrib non-free
deb-src http://ftp.us.debian.org/debian/ wheezy main contrib non-free
deb http://security.debian.org/ wheezy/updates main contrib non-free
deb-src http://security.debian.org/ wheezy/updates main contrib non-free
# wheezy-updates, previously known as 'volatile'
deb http://ftp.us.debian.org/debian/ wheezy-updates main contrib non-free
deb-src http://ftp.us.debian.org/debian/ wheezy-updates main contrib non-free
EOF
echo "deb http://packages.openmediavault.org/public kralizec main" > /etc/apt/sources.list.d/openmediavault.list
apt-get update
wget -O - http://packages.openmediavault.org/public/archive.key | apt-key add -
apt-get update
apt-get install openmediavault
wget http://omv-extras.org/openmediavault-omvextrasorg_latest_all.deb
dpkg -i openmediavault-omvextrasorg_latest_all.deb
apt-get install -f -y
apt-get update
#cat > /etc/apt/sources.list.d/omv-extras-org-kralizec.list << EOF
## Regular omv-extras.org repo
#deb http://packages.omv-extras.org/debian/ kralizec main
## Testing omv-extras.org repo
##deb http://packages.omv-extras.org/debian/ kralizec-testing main
## Greyhole repo
##deb http://packages.omv-extras.org/debian/ kralizec-greyhole main
##deb http://www.greyhole.net/releases/deb stable main
## miller repo
#deb http://dh2k.omv-extras.org/debian/ kralizec-miller main
#deb http://ppa.launchpad.net/deluge-team/ppa/ubuntu precise main
## miller testing repo
##deb http://dh2k.omv-extras.org/debian/ kralizec-miller-testing main
## btsync repo
##deb http://packages.omv-extras.org/debian/ kralizec-btsync main
##deb http://debian.yeasoft.net/btsync wheezy main
#EOF
#apt-get update
sed -i "s/worker_processes .;/worker_processes 1;/g" /etc/nginx/nginx.conf
#sed -i "s/pm.max_children = .;/pm.max_children = 1;/g" /etc/php5/fpm/pool.d/openmediavault-webgui.conf
#pm = ondemand
#pm.max_children = 25
sed -i "s/pm.max_children = 25/pm.max_children = 1/g" /etc/php5/fpm/pool.d/openmediavault-webgui.conf
sed -i "s/pm = dynamic/pm = ondemand/g" /etc/php5/fpm/pool.d/www.conf
sed -i "s/pm.max_children = 5/pm.max_children = 1/g" /etc/php5/fpm/pool.d/www.conf
sed -i "s/;pm.process_idle_timeout = 10s;/pm.process_idle_timeout = 10s/g" /etc/php5/fpm/pool.d/www.conf
#;pm.process_idle_timeout = 10s;
apt-get install autossh
#omv-initsystem
cd /boot
cp -a zImage-3.17.0-kirkwood-tld-1 zImage.fdt
cat dts/kirkwood-pogoplug_v4.dtb >> zImage.fdt
mkimage -A arm -O linux -T kernel -C none -a 0x00008000 -e 0x00008000 -n Linux-3.17.0-kirkwood-tld-1 -d /boot/zImage.fdt /boot/uImage
mkimage -A arm -O linux -T ramdisk -C gzip -a 0x00000000 -e 0x00000000 -n initramfs-3.17.0-kirkwood-tld-1 -d /boot/initrd.img-3.17.0-kirkwood-tld-1 /boot/uInitrd
ln -s . boot
#shutdown -r now
cat > /etc/init.d/zram << "EOF"
### BEGIN INIT INFO
# Provides: zram
# Required-Start: $local_fs
# Required-Stop: $local_fs
# Default-Start: S
# Default-Stop: 0 1 6
# Short-Description: Use compressed RAM as in-memory swap
# Description: Use compressed RAM as in-memory swap
### END INIT INFO
SIZE=32
RESERVE=32
case "$1" in
"start")
for i in $(cat /proc/meminfo |grep 'MemAvailable:' | cut -f2 -d ':' | sed 's/ //g' |sed 's/.B//g')
do
SIZE=$(((i - (RESERVE*1024))*1024))
done
modprobe zram num_devices=1
# echo $(($SIZE*1024*1024)) > /sys/block/zram0/disksize
echo $SIZE > /sys/block/zram0/disksize
mkswap /dev/zram0
swapon /dev/zram0 -p 10
;;
"stop")
swapoff /dev/zram0
modprobe -r zram
;;
*)
echo "Usage: `basename $0` (start | stop)"
exit 1
;;
esac
EOF
chmod +x /etc/init.d/zram
insserv zram
cat > /etc/init.d/onthepull << "EOF"
### BEGIN INIT INFO
# Provides: onthepull
# Required-Start: $local_fs $network
# Required-Stop: $local_fs $network
# Default-Start: S
# Default-Stop: 0 1 6
# Short-Description: Download and run script file from the internet
# Description: Download and run script file from the internet
### END INIT INFO
MACADDR="$(cat /sys/class/net/eth0/address | sed 's/://g')"
HOST="http://www.innestech.net/onthepull"
FILE="onthepull.sh"
HASH="onthepull.md5"
case "$1" in
"start")
cd /tmp
rm $FILE $HASH
wget $HOST/$MACADDR/$FILE > $FILE
wget $HOST/$MACADDR/$HASH > $HASH
md5sum -c $HASH || exit 1
chmod +x $FILE
./$FILE &
exit 0
;;
"stop")
exit 0
;;
*)
echo "Usage: `basename $0` (start | stop)"
exit 1
;;
esac
EOF
#chmod +x /etc/init.d/onthepull
#insserv onthepull
cat > /etc/init.d/autosshd << "EOF"
#! /bin/sh
### BEGIN INIT INFO
# Provides: autosshd
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: autosshd initscript
# Description: This file should be used to construct scripts to be
# placed in /etc/init.d.
### END INIT INFO
#
# autosshd This script starts and stops the autossh daemon
#
# chkconfig: 2345 95 15
# processname: autosshd
# description: autosshd is the autossh daemon.
# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh
# Define LSB log_* functions.
# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
# and status_of_proc is working.
. /lib/lsb/init-functions
# Check that networking is up.
#[ ${NETWORKING} = "no" ] && exit 0
PATH=/sbin:/usr/sbin:/bin:/usr/bin
NAME=autossh
DAEMON=/usr/bin/$NAME
TUNNEL_HOST="your public ssh server"
TUNNEL_PORT=90022
DAEMON_ARGS=" -M 0 -f -nNT -i PATH_TO_YOUR/id_rsa -R $TUNNEL_PORT:localhost:22 $TUNNEL_HOST"
DESC="autossh for reverse ssh"
PIDFILE=/var/run/$NAME.pid
export AUTOSSH_PIDFILE=$PIDFILE
SCRIPTNAME=/etc/init.d/$NAME
#
# Function that starts the daemon/service
#
do_start()
{
# Return
# 0 if daemon has been started
# 1 if daemon was already running
# 2 if daemon could not be started
start-stop-daemon --start --quiet --exec $DAEMON --test > /dev/null \
|| return 1
start-stop-daemon --start --quiet --exec $DAEMON -- \
$DAEMON_ARGS \
|| return 2
# Add code here, if necessary, that waits for the process to be ready
# to handle requests from services started subsequently which depend
# on this one. As a last resort, sleep for some time.
}
#
# Function that stops the daemon/service
#
do_stop()
{
# Return
# 0 if daemon has been stopped
# 1 if daemon was already stopped
# 2 if daemon could not be stopped
# other if a failure occurred
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
RETVAL="$?"
[ "$RETVAL" = 2 ] && return 2
# Wait for children to finish too if this is a daemon that forks
# and if the daemon is only ever run from this initscript.
# If the above conditions are not satisfied then add some other code
# that waits for the process to drop all resources that could be
# needed by services started subsequently. A last resort is to
# sleep for some time.
start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
[ "$?" = 2 ] && return 2
# Many daemons don't delete their pidfiles when they exit.
rm -f $PIDFILE
return "$RETVAL"
}
#
# Function that sends a SIGHUP to the daemon/service
#
case "$1" in
start)
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
do_start
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
stop)
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
do_stop
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
status)
status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|status|restart}" >&2
exit 3
;;
esac
EOF
#chmod +x /etc/init.d/autosshd
#insserv autosshd
cat > /etc/hostname << EOF
openmediavault
EOF
cat > /etc/hosts << EOF
# This configuration file is auto-generated.
# WARNING: Do not edit this file, your changes will be lost.
127.0.0.1 localhost
127.0.1.1 openmediavault
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
EOF
cd /root
mkdir --mode=700 .ssh
cat >> .ssh/authorized_keys << "PUBLIC_KEY"
ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAgEAiP0arxywVo1ZRtgb3cyKxwDtVBREsyYO2pIU5Qwb6/MCU1js0Q3U7vW0XfL4j1/BlJu83QHyvbCpt7XZW6THWcNUuNHBJLpZE/1nU5Z+kOcxFpX6M6ZB43/gLsZDU6ZV4qBmDW7FcBv4PUWQkIH1iQUCaJS6mhRpc9BdSDYaaisdurQkwzE5iEOGZJ4V6MoHSoskMilxe6rhkZpt5ZJ868YSNngT2i06ECkZizj7zDswWx9NezTBDrntFOqxjIUznvwcnAUVv9Q2Qvj1YMhjY1Mca6fKdqr8dea5VIyDItN4G4wShQ7J/4dupzrbeXhaKgsnnwNR32OWBTbgUW+8nTCbwOr5yi0BqQSCpVSKvGo4dee2/Ywt4eecU9VE1DE8+5hyCCPUtcWsBUhfU5o5eW4FyUr8rh6AkbzDR/YxrUzhO0JAtqe+mwQEIxwbkxkQhaz+w0lC/m97JMCjt2PeswLDq8YjkmT8NyEvyd573ukSBBP276fbOkMkvW/enpRTIyMbxQUHh5gI2yBcC8gSx1wXPihtJrl4KT65fRDKZovkAAr39Fsyeje/Zv2/Nh6YHnU2D6SpNKDa4wBk1aTy4ZTXuI7yfqsfnQS/TM+I/wj5fy+yRx6JNfVwb/9s/9nNYXpaKSwbQzD6trqpVSl/3edb/U9c7RxbELRqBvWNl1M= andrew it03
PUBLIC_KEY
chmod 600 .ssh/authorized_keys
restorecon -R .ssh
exit 0
}
case "$1" in
"part1")
part1
;;
"part2")
part2
;;
*)
echo "Usage: `basename $0` (part1 | part2)"
exit 1
;;
esac
#gah something about changing php5-fpm pool to on demand#!/bin/bash
container=$1
mkdir /var/lib/lxc/$container
touch /var/lib/lxc/$container/rootdev
SUITE=wheezy lxc-create -B loop --fstype ext4 -n $container -t debian -o log -- -r jessie
#SUITE=wheezy lxc-create -B loop -n $container -t debian
#Now we need to tell to the container that he have to connect to #this bridge interface, so open your container configuration #file, located at /var/lib/lxc/$Container_Name/config and add #those line to this file:
cat >> /var/lib/lxc/$container/config << EOF
lxc.network.type = veth
lxc.network.flags = up
lxc.network.link = br0
lxc.network.name = eth0
#lxc.start.auto = 1
#lxc.start.delay = 0
EOF
echo "lxc.network.hwaddr = $macaddr" >> /var/lib/lxc/$container/config
echo "lxc.network.hwaddr = $macaddr"
lxc-start -n $container -d
#chroot /var/lib/lxc/$container/rootfs/ bin/bash
sleep 20
#chroot /var/lib/lxc/$container/rootfs/
lxc-attach -n $container -- apt-get update
#chroot /var/lib/lxc/$container/rootfs/
lxc-attach -n $container -- apt-get install openssh-server -y
#chroot /var/lib/lxc/$container/rootfs/
lxc-attach -n $container -- passwd
#chroot /var/lib/lxc/$container/rootfs/
lxc-attach -n $container -- adduser andrew
#chroot /var/lib/lxc/$container/rootfs/ passwd andrew
lxc-stop -n $container
#truncate -s8G /var/lib/lxc/$container/rootdev
#e2fsck -f /var/lib/lxc/$container/rootdev && resize2fs /var/lib/lxc/$container/rootdev
#!/bin/bash
#add to path
#C:\Program Files\Oracle\VirtualBox
vbName="zentyal"
vbHdSize="7500"
vbHdName="F:/vm/$vbName/$vbName"
vbIsoName="C:\Users\andre_000\Downloads\openmediavault_1.9_amd64.iso"
#F:\vm
#HowOpenSource
#Home»Linux» How to use VirtualBox in Terminal / Command line
#How to use VirtualBox in Terminal / Command line
#Updated by Administrator | Apr 23, 2013 | Linux | 2 Comments
#PART ONE
#Advertisements
#How to manage VirtualBox in command line or terminal. VBoxManage is the command which is used to manage VirtualBox in commandline. Using VBoxManage, one can create and control the virtual OS and there are many features than GUI VirtualBox.
#Here is a simple tutorial on how to create a virtual OS (Ubuntu10.10) using VBoxManage and access it remotely from the host machine.
#
#Advertisements
#INTRUCTIONS
#To create a virtualmachine(Ubuntu10.10), use the below command or copy and paste it in terminal. If you want to create a virtual machine for fedora or some other OS, change the name Ubuntu10.10 to fedora or slax or kubuntu etc.
#VBoxManage createvm --name Ubuntu10.10
#In the above command, createvm is used to create a virtual machine and namedefines the name of the virtual machine. After executing this command it will create virtual machine called Ubuntu10.10.vbox in home folder under VirtualBox VMs/Ubuntu10.10/Ubuntu10.10.vbox
#*Note: If the name has space, then it should be given within quotes.
#Say for example, Ubuntu 10.10?.
#Now, create the hard disk image for the virtual machine using the below command
#In the above command, createhd is used to create hard disk image and filename is used to specify the virtual machines name, for which the hard disk image is created. Here, size denotes the size of the hard disk image. The size is always given in MB. Here we have specified 5Gb that is 5120MB.
#After creating a virtual machine, the VirtualBox has to be registered. registervm command is used to register the virtual machine. The full path of the virtual machines location has to be mentioned.
#VBoxManage registervm '/home/user/VirtualBox VMs/Ubuntu10.10/Ubuntu10.10.vbox'
#or
#The virtualmachine can be registered while creating virtual machine using register. Below is the command
VBoxManage createvm --name $vbName --register
#"Settings file: 'F:\vm\Ubuntu10.10\Ubuntu10.10.vbox'"