summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xdownload-pkg2
-rwxr-xr-ximgur.sh8
-rwxr-xr-xqinit80
-rwxr-xr-xremote-notify-client.sh12
-rw-r--r--setup-arch-vm66
-rwxr-xr-xsetup-qemu-env10
-rwxr-xr-xsftp-mount.sh13
-rwxr-xr-xxob4
8 files changed, 195 insertions, 0 deletions
diff --git a/download-pkg b/download-pkg
new file mode 100755
index 0000000..04b31f7
--- /dev/null
+++ b/download-pkg
@@ -0,0 +1,2 @@
+#!/bin/sh
+curl -O $(pacman -Spwdd "$@")
diff --git a/imgur.sh b/imgur.sh
new file mode 100755
index 0000000..4a8932f
--- /dev/null
+++ b/imgur.sh
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+TEMPDIR=$(mktemp -d)
+trap "rm -rf '${TEMPDIR}'" EXIT TERM
+
+curl -s -F "image=@$1" -F "key=486690f872c678126a2c09a9e196ce1b" \
+https://imgur.com/api/upload.xml > "$TEMPDIR/imgur.xml"
+xmllint "$TEMPDIR/imgur.xml" --xpath '//original_image/text()' | xclip
diff --git a/qinit b/qinit
new file mode 100755
index 0000000..bdece6e
--- /dev/null
+++ b/qinit
@@ -0,0 +1,80 @@
+#!/bin/bash
+#
+# launcher script for qemu-kvm
+#
+# machines are sourced from a file which defines functions, each
+# specifying options for the particular VM, for example:
+#
+# vm_beatbox() {
+# net+=",mac=de:ad:be:ef:00:01"
+# cdrom="-cdrom $isoroot/archlinux-2011.05.08-core-x86_64.iso -boot d"
+#
+# opts=(-nographic)
+# drives=(
+# "-drive file=$imgroot/beatbox.1.qcow2,if=virtio"
+# "-drive file=$imgroot/beatbox.2.qcow2,if=virtio"
+# )
+# }
+#
+# If unspecified:
+# ${drives[@]}: will match all of "$imgroot/$vm".*.qcow2
+#
+
+shopt -s nullglob
+
+### Paths ################################
+#declare config_root=/mnt/levant/nfs/tmp/Florian/qemu
+declare config_root=/mnt/data/qemu
+declare -r machines=$config_root/machines
+declare isoroot=$config_root
+declare imgroot=$config_root
+
+### Defaults #############################
+declare mem="-m 1024"
+declare cpus="-cpu host -smp 4"
+#declare net="-net vde -net nic,model=virtio"
+declare net="-netdev bridge,br=br-qemu,id=mynet0 -device virtio-net,netdev=mynet0"
+cdrom+=("-boot" "d")
+
+#declare cdrom="-cdrom $isoroot/archlinux-2012.11.01-dual.iso -boot d"
+for iso in "$isoroot/"archlinux-*.iso; do
+ cdrom+=("-cdrom" "$iso")
+done
+### Launcher #############################
+
+. "$machines"
+
+while getopts 'c' flag; do
+ case $flag in
+ c) usecdrom=true ;;
+ esac
+done
+shift $(( OPTIND - 1 ))
+
+if [[ -z $1 ]]; then
+ printf 'Available VMs:\n'
+ compgen -A function -- vm_ | sed 's/^vm_/ /'
+ exit 0
+fi
+
+vm=$1; shift
+if ! type -t vm_$vm >/dev/null; then
+ printf 'unknown VM: %s\n' "$vm"
+ exit 1
+fi
+
+vm_$vm
+
+# default drives
+if (( ${#drives[*]} == 0 )); then
+ for drive in "$imgroot/$vm".*.raw; do
+ drives+=("-drive" "file=$drive,if=virtio,format=raw")
+ done
+
+ for drive in "$imgroot/$vm".*.qcow2; do
+ drives+=("-drive" "file=$drive,if=virtio")
+ done
+fi
+
+exec qemu-system-x86_64 --machine type=pc,accel=kvm "${opts[@]}" $cpus $mem "${drives[@]}" $net ${usecdrom:+${cdrom[@]}} "$@"
+
diff --git a/remote-notify-client.sh b/remote-notify-client.sh
new file mode 100755
index 0000000..a95c9e7
--- /dev/null
+++ b/remote-notify-client.sh
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+[[ -z $DISPLAY ]] && exit 1;
+
+exec 0<&-
+
+sup ssh mistral 'socat unix-connect:notify.sock stdout' |
+ while read heading message; do
+ if [[ -n $heading ]]; then
+ notify-send -t 5000 -- "${heading}" "${message}";
+ fi
+ done
diff --git a/setup-arch-vm b/setup-arch-vm
new file mode 100644
index 0000000..eb8d949
--- /dev/null
+++ b/setup-arch-vm
@@ -0,0 +1,66 @@
+#!/bin/bash
+
+set -e
+
+newuser="flo"
+
+mkfs.ext4 /dev/vda
+mount /dev/vda /mnt
+cat <<EOF >/etc/pacman.d/mirrorlist
+Server = http://mirror.server-speed.net/\$repo/os/\$arch
+EOF
+
+pacstrap /mnt base syslinux sudo openssh haveged htop git
+genfstab -p /mnt >> /mnt/etc/fstab
+echo "archvm" > /mnt/etc/hostname
+ln -s /usr/share/zoneinfo/Europe/Athens /mnt/etc/localtime
+echo "en_US.UTF-8 UTF-8" > /mnt/etc/locale.gen
+arch-chroot /mnt locale-gen
+
+echo "LANG=en_US.UTF-8" > /mnt/etc/locale.conf
+cat <<EOF > /mnt/etc/vconsole.conf
+KEYMAP=de
+FONT=
+EOF
+
+cat <<EOF >/mnt/boot/syslinux/syslinux.cfg
+serial 0 115200
+DEFAULT arch
+PROMPT 0
+TIMEOUT 50
+
+LABEL arch
+ MENU LABEL Arch Linux
+ LINUX ../vmlinuz-linux
+ APPEND root=/dev/vda ro logo.nologo elevator=deadline console=tty0 console=ttyS0
+ INITRD ../initramfs-linux.img
+EOF
+
+cat <<EOF > /mnt/etc/modprobe.d/modprobe.conf
+blacklist cirrus
+EOF
+
+arch-chroot /mnt mkinitcpio -p linux
+# expected error: /dev/vda - is a block device. Aborting set_active!
+# TODO: create partitions and remove the || true
+arch-chroot /mnt syslinux-install_update -aim || true
+arch-chroot /mnt useradd -m -g users -G wheel $newuser
+mkdir /mnt/root/.ssh
+touch /mnt/root/.ssh/authorized_keys
+chmod 700 /mnt/root/.ssh
+chmod 600 /mnt/root/.ssh/authorized_keys
+cat <<EOF > /mnt/root/.ssh/authorized_keys
+ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAte43fgKVPKvmwhMQcQRYNm27i2cadOIJvpOFA3jPWHFN2YeqxHvgVbAESLOAO/sJ0MqXlQnBc9rr8PbQd67YP7teOBnXLOfX2mofxGEDtP2mtwneAxkMNJcYtxWjPeKL7LF5tknqPb6dXavm4+gJt27CQFFY6DJ+cD0tUUgh17HG6VGiTXF6AgB9aho/ToaMQZ4vCzztvf94kQK2uBYUXsvx4L62ZrEJbIzfB7fynBbl9+deBqsYmWRCbzaYV77YjwLhk9hI/GsUjLkTAB77WbeWJdk7fgJ/PgI69FRMhRlYASRVBqeek6NLcyQ9x54CrUkOFBC5Q+j4yjsDQN7NBw== flo@Marin
+EOF
+
+mkdir /mnt/home/$newuser/.ssh
+chmod 700 /mnt/home/$newuser/.ssh
+cp /mnt/root/.ssh/authorized_keys /mnt/home/$newuser/.ssh/authorized_keys
+chmod 600 /mnt/home/$newuser/.ssh/authorized_keys
+arch-chroot /mnt chown -R $newuser:users /home/$newuser/.ssh
+arch-chroot /mnt passwd -d $newuser
+
+arch-chroot /mnt systemctl enable sshd multi-user.target haveged dhcpcd.service
+
+sync
+systemctl poweroff
diff --git a/setup-qemu-env b/setup-qemu-env
new file mode 100755
index 0000000..1fe9319
--- /dev/null
+++ b/setup-qemu-env
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+#brctl addbr br-qemu
+ip link add br-qemu type bridge
+
+ip addr add 10.0.2.1/24 brd + dev br-qemu
+ip link set br-qemu up
+iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
+
+dnsmasq -i br-qemu --dhcp-leasefile=/tmp/qemu-dhcpd.leases --dhcp-range=10.0.2.2,10.0.2.100,30m #-M "arch/boot/syslinux/gpxelinux.0,,192.168.4.1"
diff --git a/sftp-mount.sh b/sftp-mount.sh
new file mode 100755
index 0000000..e2fb3ae
--- /dev/null
+++ b/sftp-mount.sh
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+set -e
+
+mnt=~/mnt/$1
+
+if ! mountpoint -q $mnt; then
+ mkdir -p $mnt
+ sshfs web-$1@karif: $mnt
+else
+ fusermount -u $mnt
+ rmdir $mnt
+fi
diff --git a/xob b/xob
new file mode 100755
index 0000000..839097f
--- /dev/null
+++ b/xob
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+xo "$@" &
+disown