summaryrefslogtreecommitdiffstats
path: root/ship/src/filehooker_install
blob: eb2d5fd1c4c94a49edb019b8bb5ba53e37bac6f9 (plain)
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
#/bin/sh
#@info
#@strict
#@include core
## colored logging
#@include color
#@include network

## for tor hidden service
#@include tor

## for ncdc
#@include filehooker
pass=lolwut.aidsballs
# 20gig
#min_netshare_size=20000000000
admin=pimp
extra_pkg="vim sudo grub-bios ntp tor openssh btrfs-progs tmux"

info "writing stdout to /tmp/install.log"


installer_disk(){
    find /dev/disk/by-label/ -name ARCH_\* 2>/dev/null | xargs readlink
}

find_rootdisk(){
    for i in sd vd hd;do
        for j in a b c;do
            dsk="/dev/$i$j"
            test ! -e "$dsk" && continue
            test "$(installer_disk)" == "$dsk" && continue
            test "$(get_disksize $dsk)" -gt "$min_netshare_size" && info "not using $dsk as it is too big" && continue
            echo "$dsk" && return
        done
    done
}

rootdisk=$(find_rootdisk)
test "$rootdisk" || die "cannot find your root disk"

info "Your rootdisk is $rootdisk"
sleep 3

umount /mnt/boot ||:
umount /mnt ||:
info "overwriting partitioning"
dd if=/dev/zero of=$rootdisk bs=2k count=10
info "starting partitioning"
(printf "o\nn\np\n\n\n+128M\n\a\nn\np\n\n\n\nw\n\n") |fdisk $rootdisk ||:
partprobe $rootdisk
info "done partitioning"
sleep 1
info "generating filesystem on /boot"
mkfs.ext2 ${rootdisk}1
info "Done"
sleep 3
sync
vgchange -an
info "generating filesystems"
mkfs.btrfs -f ${rootdisk}2
sleep 1
info "finished generating filesystems"
sleep 1
info "mounting"
mount ${rootdisk}2 /mnt
mkdir /mnt/boot
mount ${rootdisk}1 /mnt/boot

info "finished mounting!"
sleep 1
info "installing!"

info "Setting http proxy"

info "Installing the following packages: $extra_pkg"
if [ -n "${user_pkg:-}" ] ;then
  info "User chooses additional packages: $user_pkg"
else
  info "No additional packages set by user (\$user_pkg unset)"
fi
pacstrap /mnt base $extra_pkg ${user_pkg:-}
info "installation done"
sleep 1
info "generating configs"
genfstab -U -p /mnt > /mnt/etc/fstab

info "beginning chroot!"
########### BEGIN CHROOT #####
arch-chroot /mnt << EOF
#@strict
msg() { printf "\$*\n" >&2; }
info()  { msg "$green\$*$nc"; }
error() { msg "$green\$*$nc"; }

info "generating locales"
ln -s /usr/share/zoneinfo/Europe/Berlin /etc/localtime
echo "LANG=en_US.UTF-8"  >> /etc/locale.conf
echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen
locale-gen
echo "filehooker$RANDOM" > /etc/hostname
info "Done! "
mkinitcpio -p linux ||
info "setting root password"
printf "${pass}\n${pass}\n" | (passwd )
info "adding user"
useradd -m -G audio,video,wheel $admin
printf "${pass}\n${pass}\n" | (passwd $admin)

info "editing sudoers"
printf "root ALL=(ALL) ALL\n%s ALL=(ALL)NOPASSWD: ALL\n" %wheel >> /etc/sudoers
for i in dhcpcd ntpd tor sshd ; do
    info "enabling \$i"
    systemctl enable \$i
done

info "installing grub"
grub-install ${rootdisk} 2>/dev/null
#echo "GRUB_DISABLE_LINUX_UUID=true" >> /etc/default/grub
grub-mkconfig > /boot/grub/grub.cfg 2>/dev/null
# prepare ncdc
useradd -m hooker
exit
EOF
######## END CHROOT ##########
sync

info "configuring tor"
torrc=/mnt/etc/tor/torrc
hidden_service_dir=/var/lib/tor/hidden_service/
configure_hidden_service
#info "publishing hidden service address"
#cat $hidden_service_dir/hostname | send_irc
info "configure ncdc"
curl conf.krebsco.de/filehooker_configure_ncdc | arch-chroot /mnt
info "configuring netshares"
( curl conf.krebsco.de/filehooker_configure_netshare )| arch-chroot /mnt
info "configuring tor announce"
curl conf.krebsco.de/install_tor_announce | arch-chroot /mnt
info "We're all done, rebooting!"
sync
sleep 5
reboot