diff options
author | root <root@flap> | 2014-05-06 10:00:33 -0400 |
---|---|---|
committer | root <root@flap> | 2014-05-06 10:00:33 -0400 |
commit | 4d8016064edd5e5dc1d194ea5ec0fce4f07b8f2a (patch) | |
tree | d8ecba8651604e51d6f887449641ac627844ae63 /ship/src | |
parent | f44c8529e6d04b557d93cc862599b956ed21f0de (diff) | |
parent | d0367082a5c1296cefed641b4eda736b29a3ad69 (diff) |
Merge branch 'master' of https://github.com/krebscode/painload
Diffstat (limited to 'ship/src')
-rwxr-xr-x | ship/src/arch_autoinstall | 17 | ||||
-rwxr-xr-x | ship/src/bootstrap_env_makefu | 99 | ||||
-rw-r--r-- | ship/src/filehooker_configure_ncdc | 15 | ||||
-rw-r--r-- | ship/src/filehooker_configure_netshare | 7 | ||||
-rwxr-xr-x | ship/src/filehooker_install | 143 | ||||
-rw-r--r-- | ship/src/find-supers-tinc | 6 | ||||
-rwxr-xr-x | ship/src/fix_dircolors | 2 | ||||
-rw-r--r-- | ship/src/install_tor_announce | 5 | ||||
-rw-r--r-- | ship/src/refresh-super-keys | 5 | ||||
-rw-r--r-- | ship/src/refresh-supers | 35 | ||||
-rwxr-xr-x | ship/src/remaster_arch_shack_installstick (renamed from ship/src/remaster_arch_iso) | 25 | ||||
-rw-r--r-- | ship/src/vim_sane_defaults | 11 |
12 files changed, 297 insertions, 73 deletions
diff --git a/ship/src/arch_autoinstall b/ship/src/arch_autoinstall index baa9e2a0..c9b6c4d4 100755 --- a/ship/src/arch_autoinstall +++ b/ship/src/arch_autoinstall @@ -3,13 +3,12 @@ #@include core #@include color #@include network +#@include tor pass=shackit shack_printer_ip=10.42.0.135 extra_pkg="xorg vim xfce4 feh chromium zsh sudo git flashplugin alsa-oss alsa-lib alsa-utils grub-bios slim ntp tor network-manager-applet networkmanager openssh cups cups-filters" info "writing stdout to /tmp/install.log" -exec >> /tmp/install.log -tail -f /tmp/install.log& defer 'pkill tail' installer_disk(){ @@ -35,7 +34,7 @@ sleep 3 umount /mnt/boot ||: umount /mnt ||: info "starting partitioning" -(printf "o\nn\np\n\n\n+256M\n\a\nn\np\n\n\n\nw\n\n") |fdisk $rootdisk +(printf "o\nn\np\n\n\n+256M\n\a\nn\np\n\n\n\nw\n\n") |fdisk $rootdisk||: info "done partitioning" sleep 1 info "generating filesystem on /boot" @@ -84,7 +83,7 @@ info "generating configs" genfstab -U -p /mnt > /mnt/etc/fstab info "beginning chroot!" -arch-chroot /mnt | tee -a /tmp/install.log << EOF +arch-chroot /mnt << EOF msg() { printf "\$*\n" >&2; } info() { msg "$green\$*$nc"; } @@ -119,7 +118,7 @@ done ### CUPS mkdir -p /etc/cups -cat >>/etc/cups/printers.conf<<EOF +cat >>/etc/cups/printers.conf<<EOT <Printer HP_LaserJet_5000_Series> Info Shack Printer HP 5000 Location lounge @@ -137,7 +136,7 @@ KLimit 0 OpPolicy default ErrorPolicy stop-printer </Printer> -EOF +EOT info "installing grub" grub-install ${rootdisk} 2>/dev/null @@ -155,7 +154,11 @@ EOF info "configuring tor" torrc=/mnt/etc/tor/torrc hidden_service_dir=/var/lib/tor/hidden_service/ -#@include tor configure_hidden_service +#TODO publish tor address after reboot +#info "publishing hidden service address" +#cat $hidden_service_dir/hostname | send_irc + info "We're all done, simply reboot!" +reboot diff --git a/ship/src/bootstrap_env_makefu b/ship/src/bootstrap_env_makefu index 7ec59a79..e61f4e99 100755 --- a/ship/src/bootstrap_env_makefu +++ b/ship/src/bootstrap_env_makefu @@ -4,10 +4,24 @@ #@strict #@include core #@include punani +#@include vim + +# vim +python +_punanidb_pacman_vim_python=gvim +_punanidb_yum_vim_python=vim-enhanced +_punanidb_aptget_vim_python=vim + +# TODO pull out youcompleteme into a vim function +# cmake ,make,g++,python-dev for youcompleteme +_punanidb_pacman_cmake=cmake +_punanidb_yum_cmake=cmake +_punanidb_aptget_cmake=cmake +#@mainifyme + info "Configuring environment for $(id -un)" cd $(readlink -f $(dirname $0)) info "Using punani to install git vim and zsh" -punani install git vim zsh || error "cannot install some shit" +punani install git vim_python zsh gpp cmake make python2_dev || die "cannot install some shit" info "writing dotfiles" # deploying zshrc @@ -54,8 +68,13 @@ test -r ~/TODO && cat ~/TODO setopt menu_complete unsetopt correct_all +export PYTHONSTARTUP=~/.pythonrc +EOF +info 'deploying pythonrc' +cat > $HOME/.pythonrc <<EOF +import rlcompleter, readline +readline.parse_and_bind('tab:complete') EOF - info "deploying vim config" if [ -e $HOME/.vim ] ; then oldvim=$HOME/.vim.`date +%Y%M%d` @@ -68,43 +87,36 @@ mkdir -p $HOME/.vim # TODO modilarize vimconfig cat > $HOME/.vim/vimrc <<EOF -set nocompatible filetype off set rtp+=~/.vim/bundle/vundle call vundle#rc() - " TODO refactor this Bundle 'gmarik/vundle' Bundle 'SudoEdit.vim' Bundle 'snipMate' Bundle 'tpope/vim-fugitive' -Bundle 'vim-scripts-iptables' -Bundle 'pyflakes' +Bundle 'Valloric/YouCompleteMe' +Bundle 'scrooloose/syntastic' +Bundle 'sjl/gundo.vim' + +nnoremap <F5> :GundoToggle<CR> +set undodir=~/.vim/undo +set undofile +"maximum number of changes that can be undone +set undolevels=1000000 +"maximum number lines to save for undo on a buffer reload +set undoreload=10000000 + +set pastetoggle=<F2> +set showmode +filetype plugin indent on + filetype plugin indent on -syntax on -set vb let g:snips_author = 'Bob Ross <root@syntax-fehler.de>' let g:makefu_author = 'makefu' -set foldenable -set foldmethod=syntax -" shows matching braches etc -set showmatch -set matchtime=3 -" highlight search -set hlsearch - -" set noswapfile -" set nobackup -set backupdir=~/.vim/backup -set directory=~/.vim/backup - -" turn off F1 -inoremap <F1> <ESC> -nnoremap <F1> <ESC> -vnoremap <F1> <ESC> " pasting nnoremap <F2> :set invpaste paste?<CR> set pastetoggle=<F2> @@ -114,44 +126,31 @@ set showmode au FocusLost * :wa set spelllang=en -" use set spell to enable spelling - -" press ttt to rot16 the whole file -nmap ttt ggg?G -colorscheme darkblue -set background=dark - -set number -set mouse= set textwidth=9001 -set ignorecase -set incsearch -set wildignore=*.o,*.obj,*.bak,*.exe,*.os - -set shiftwidth=2 -set tabstop=2 -set et -set sw=2 -set smarttab -set autoindent -" end tabstop -set backspace=indent,eol,start -set nocp autocmd BufRead *.json set filetype=json EOF - +if [ -e $HOME/.vimrc ] ; then + oldvim=$HOME/.vimrc.`date +%Y%M%d` + info "Backing up old vimrc file to $oldvim" + mv -v $HOME/.vimrc $oldvim +fi +info "Symlinking .vimrc to .vim/vimrc" ln -vs $HOME/.vim/vimrc $HOME/.vimrc +vim_conf_sane_defaults #install all the vim stuff with the help of vundle cd $HOME/.vim -mkdir bundle -mkdir backup +mkdir -p bundle undo backup info "Fetching vim-vundle" git clone https://github.com/gmarik/vundle.git bundle/vundle > /dev/null && \ info "Vim Vundle deployed" info "Installing Vundle Bundles" vim "+:BundleInstall" "+:qall" + +info "building youcompleteme libs" +cd $HOME/.vim/bundle/YouCompleteMe +./install.sh cd - info "configuring zsh" diff --git a/ship/src/filehooker_configure_ncdc b/ship/src/filehooker_configure_ncdc new file mode 100644 index 00000000..c980ebf2 --- /dev/null +++ b/ship/src/filehooker_configure_ncdc @@ -0,0 +1,15 @@ +#!/bin/sh +#@info +#@strict +#@include filehooker + +dc_hub="adcs://elch.nsupdate.info:2781" +rnd=`hexdump -n 2 -e '/2 "%u"' /dev/urandom` +nick="filehooker_$rnd" + + +ncdc_install +ncdc_autostart + +ncdc_configure_nick "$nick" +ncdc_configure_hub "$dc_hub" diff --git a/ship/src/filehooker_configure_netshare b/ship/src/filehooker_configure_netshare new file mode 100644 index 00000000..438ac133 --- /dev/null +++ b/ship/src/filehooker_configure_netshare @@ -0,0 +1,7 @@ +#!/bin/sh +#@info +#@strict +#@include filehooker +for i in $(prepare_netshares) ;do + ncdc_configure_netshare "$i" "${i##*/}" +done diff --git a/ship/src/filehooker_install b/ship/src/filehooker_install new file mode 100755 index 00000000..eb2d5fd1 --- /dev/null +++ b/ship/src/filehooker_install @@ -0,0 +1,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 diff --git a/ship/src/find-supers-tinc b/ship/src/find-supers-tinc new file mode 100644 index 00000000..3ea53d35 --- /dev/null +++ b/ship/src/find-supers-tinc @@ -0,0 +1,6 @@ +#!/bin/sh +#@info +#@include core +#@include retiolum + +find_supernodes diff --git a/ship/src/fix_dircolors b/ship/src/fix_dircolors index b2e2ffdb..d427563f 100755 --- a/ship/src/fix_dircolors +++ b/ship/src/fix_dircolors @@ -6,7 +6,7 @@ exists dircolors || die "no dircolors in PATH, bailing out" info "fixing dircolors for $(id -un)" dircolors -p > $HOME/.dircolors -sed -i 's/\(DIR \).*/\101;35/' $HOME/.dircolors +sed -i 's/\(DIR \).*/\101;36/' $HOME/.dircolors ! grep -q 'dircolors' $HOME/.profile && \ info "adding dircolors line to $HOME/.profile" && \ echo 'eval `dircolors -b $HOME/.dircolors`' >> $HOME/.profile diff --git a/ship/src/install_tor_announce b/ship/src/install_tor_announce new file mode 100644 index 00000000..b7b3662e --- /dev/null +++ b/ship/src/install_tor_announce @@ -0,0 +1,5 @@ +#!/bin/sh +#@strict +#@include filehooker + +install_tor_announce diff --git a/ship/src/refresh-super-keys b/ship/src/refresh-super-keys new file mode 100644 index 00000000..dddbe846 --- /dev/null +++ b/ship/src/refresh-super-keys @@ -0,0 +1,5 @@ +#!/bin/sh +#@info +#@include retiolum +#@mainifyme +refresh_supernode_keys diff --git a/ship/src/refresh-supers b/ship/src/refresh-supers new file mode 100644 index 00000000..6dc6e8ab --- /dev/null +++ b/ship/src/refresh-supers @@ -0,0 +1,35 @@ +#!/bin/sh +#@info +# usage: [DEBUG=1] [tincconf=/not/tinc/retiolum/tinc.conf] $0 +# This is the implementation of the proposal how to update tinc supernode +# connections + +#@include core +#@include retiolum + # using find_supernodes + # tinc_path + # netname + +#@strict +#@mainifyme + +refresh_supernode_keys + +max_connect_to=${max_connect_to:-5} +tincconf=${tincconf:-$tinc_path/$netname/tinc.conf} +tmp_tincconf=$(mktemp) +defer "rm -f $tmp_tincconf" + +sed '/^[ ]*ConnectTo/d' "$tincconf" > "$tmp_tincconf" + + +# TODO find_supernodes requires netcat +find_supernodes | cut -d\ -f 1 | shuf \ + | head -n "${max_connect_to}" \ + | xargs -n1 printf "ConnectTo=%s\n" >> "$tmp_tincconf" + +info "replacing old tinc.conf with one" +test "${DEBUG:-}" && diff "$tincconf" "$tmp_tincconf" +mv "$tmp_tincconf" "$tincconf" + +reload_tinc diff --git a/ship/src/remaster_arch_iso b/ship/src/remaster_arch_shack_installstick index 94a750c1..3ad985af 100755 --- a/ship/src/remaster_arch_iso +++ b/ship/src/remaster_arch_shack_installstick @@ -1,5 +1,6 @@ #!/bin/sh #@include core +#@include iso #@mainifyme ## TODO: provide a parameter which defines what to be done in the new iso root @@ -12,14 +13,13 @@ isodir=$bdir/iso isomnt=$bdir/isomount rootdir=$bdir/root outdir=$bdir/out -auto_url=euer.krebsco.de/autoinstall +auto_url=${2:-conf.krebsco.de/arch_autoinstall} info "bdir is at $bdir" [ ! -e "$isofile" ] && die "$isofile does not exist." esudo "$@" - - -#punani install genisoimage - +arch_label="$(get_volid "$isofile")" +info "Arch iso label is ${arch_label}" +info "auto_url is $auto_url" info "cleanup root dir" rm -rf $bdir @@ -59,12 +59,11 @@ Just Wait until everything finished. - Make sure that RJ45 is connected - you can bail out of the progress at any time with CTRL-C -- if anything went wrong,you can run the installer again at: - /krebs/autoinstall - + /krebs/autoinstall (args) EOD /krebs/autoinstall EOL + mkdir /krebs cat > /krebs/autoinstall <<EOL internet() { ping -w 1 google.de >/dev/null 2>&1; } @@ -76,7 +75,7 @@ done echo "Grabbing current version of install-script from $auto_url" echo echo "AGENTS ARE GOOOOOOOOOOO!" -curl $auto_url 2>/dev/null | sh +curl "$auto_url" 2>/dev/null | sh -s "\\\$@" EOL chmod 755 /krebs/autoinstall EOF @@ -84,19 +83,15 @@ EOF rm "$isodir/arch/$arch/root-image.fs.sfs" info "creating squashfs at $isodir/arch/$arch/root-image.fs.sfs" umount "$rootdir/$arch" - mksquashfs "$outdir/$arch/root-image.fs" "$isodir/arch/$arch/root-image.fs.sfs" + mksquashfs "$outdir/$arch/root-image.fs" "$isodir/arch/$arch/root-image.fs.sfs" done info "creating Iso Image" -#genisoimage -l -r -J -V "ARCH_$(date +%Y%m)" \ -# -b isolinux/isolinux.bin -no-emul-boot \ -# -boot-load-size 4 -boot-info-table -c isolinux/boot.cat \ -# -o "$outdir/$outfile" "$isodir" rm -f "${outdir}/${outfile}" xorriso -as mkisofs \ -iso-level 3 \ -full-iso9660-filenames \ - -volid "ARCH_201311" \ + -volid "${arch_label}" \ -appid "Shackspace Krebs Installer" \ -publisher "Shackspace/Krebs" \ -preparer "prepared by krebs" \ diff --git a/ship/src/vim_sane_defaults b/ship/src/vim_sane_defaults new file mode 100644 index 00000000..4c6f1b8f --- /dev/null +++ b/ship/src/vim_sane_defaults @@ -0,0 +1,11 @@ +#!/bin/sh +#@strict +#@include core +#@include vim +#@include punani +#@mainifyme +info "installing punani" +punani install vim +touch $vimrc +info "configuring vim" +vim_conf_sane_defaults |