├── .gitignore ├── README.md └── vagrant ├── Makefile ├── README.md ├── scripts ├── blackarch.sh ├── cleanup.sh ├── pacman.sh ├── update.sh ├── vagrant.sh ├── virtualbox.sh ├── yaourt.sh ├── zerodisk.sh └── zsh.sh └── template.json /.gitignore: -------------------------------------------------------------------------------- 1 | docker/output/* 2 | !docker/output/build-helper.sh 3 | !docker/output/build-pacman.conf 4 | !docker/output/build.sh 5 | 6 | vagrant/vagrant_cache 7 | vagrant/output* 8 | vagrant/.vagrant 9 | vagrant/packer_cache 10 | vagrant/testing 11 | pkg/ 12 | src/ 13 | trunk/ 14 | 15 | *.swp 16 | *~ 17 | *.tmp 18 | tags 19 | 20 | .MTREE 21 | .PKGINFO 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Description 2 | 3 | Images and scripts for virtualization 4 | 5 | This repository contains various build scripts to build BlackArch images for several virtualization technologies. 6 | For more information about each image, please refer to the README in the particular directory. 7 | 8 | ## Get Involved 9 | 10 | You can get in touch with the BlackArch Linux team. Just check out the 11 | following: 12 | 13 | **Please, send us pull requests!** 14 | 15 | **Web:** https://www.blackarch.org/ 16 | 17 | **Mail:** team@blackarch.org 18 | 19 | **IRC:** [irc://irc.freenode.net/blackarch](irc://irc.freenode.net/blackarch) 20 | -------------------------------------------------------------------------------- /vagrant/Makefile: -------------------------------------------------------------------------------- 1 | BUILD_DIR ?= ./output 2 | TEST_DIR ?= ./testing 3 | BOX_NAME ?= blackarch 4 | PROVIDER ?= virtualbox 5 | BOX_FILENAME ?= $(BOX_NAME)_$(PROVIDER).box 6 | BOX_DEFINITION ?= ./template.json 7 | PACKER ?= packer-io 8 | 9 | .PHONY: all clean deepclean validate build update 10 | 11 | all: build 12 | 13 | build: $(BUILD_DIR)/$(BOX_FILENAME) 14 | 15 | update: 16 | scripts/update.sh 17 | 18 | clean: 19 | rm -rf $(BUILD_DIR) 20 | ( cd $(TEST_DIR) && \ 21 | vagrant destroy -f && \ 22 | cd .. ) || true 23 | rm -rf $(TEST_DIR) 24 | rm -f *.{hwm,pwd,pwi} 25 | 26 | deepclean: clean 27 | rm -rf ./packer_cache 28 | 29 | validate: 30 | $(PACKER) validate $(BOX_DEFINITION) 31 | 32 | $(BUILD_DIR)/$(BOX_FILENAME): validate 33 | $(PACKER) build -var 'git_revision=$(shell git rev-parse --abbrev-ref HEAD):$(shell git rev-parse --verify HEAD)' $(BOX_DEFINITION) 34 | 35 | test: 36 | echo $(BUILD_DIR)/$(BOX_FILENAME) 37 | vagrant box add --force $(BOX_NAME) $(BUILD_DIR)/$(BOX_FILENAME) && \ 38 | mkdir -pv $(TEST_DIR) && \ 39 | cd $(TEST_DIR) && \ 40 | ( vagrant destroy -f || true ) && \ 41 | ( rm ./Vagrantfile || true ) && \ 42 | vagrant init --minimal $(BOX_NAME) && \ 43 | vagrant up && \ 44 | ( vagrant ssh -c "uname -a" | grep Linux | grep -q ARCH ) && echo TEST OK: Can connect to VM. || echo TEST FAIL: VM connect && \ 45 | ( vagrant ssh -c "ls /vagrant" | grep -q Vagrantfile ) && echo TEST OK: Shared folders are mounted in VM. || echo TEST FAIL: Shared folders. && \ 46 | vagrant destroy -f 47 | -------------------------------------------------------------------------------- /vagrant/README.md: -------------------------------------------------------------------------------- 1 | # Packer.io Template 2 | 3 | ## Introduction 4 | 5 | In this repo you find everything you need to generate a Vagrant basebox of BlackArch. We install a minimal ArchLinux and then add BlackArch on top via [`strap.sh`](https://github.com/BlackArch/blackarch-site/blob/master/strap.sh). 6 | This is based on the [GPL-licenced](https://github.com/kornrunner/packer-arch/blob/12748faaa76933281046cc5206c59436ffd75434/LICENSE) [kornrunner/packer-arch](https://github.com/kornrunner/packer-arch/tree/12748faaa76933281046cc5206c59436ffd75434). 7 | 8 | ## Prerequisites 9 | 10 | * [`aur/packer-io`](https://aur.archlinux.org/packages/packer-io/) 11 | * [`community/vagrant`](https://www.archlinux.org/packages/community/x86_64/vagrant/) 12 | * [`community/virtualbox`](https://www.archlinux.org/packages/community/x86_64/virtualbox/) including [host modules](https://wiki.archlinux.org/index.php/VirtualBox#Load_the_VirtualBox_kernel_modules) 13 | 14 | ## Usage 15 | 16 | All actions are implemented as `make` targets. 17 | 18 | * *clean*: clean output directories 19 | * *deepclean*: clean output directories and Packer cache 20 | * *validate*: validate the template JSON 21 | * *test*: run rudimentary tests against a built image 22 | * *build*: build image 23 | * *update*: update image url and checksum 24 | 25 | 26 | A typical build can be triggered with 27 | 28 | make clean update build test 29 | -------------------------------------------------------------------------------- /vagrant/scripts/blackarch.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | TERM=${TERM:-xterm} 6 | export TERM 7 | 8 | export GNUPGHOME=${HOME}/.gnupg/ 9 | curl https://www.blackarch.org/strap.sh | bash 10 | NUMPKGS=$(/usr/bin/yaourt -Ss blackarch | /usr/bin/grep -v "^ " | /usr/bin/wc -l) 11 | echo "$NUMPKGS" BlackArch packages available. 12 | -------------------------------------------------------------------------------- /vagrant/scripts/cleanup.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | /usr/bin/paccache -rk0 6 | /usr/bin/pacman -Rcns --noconfirm gptfdisk 7 | /usr/bin/pacman -Scc --noconfirm 8 | rm /tmp/yaourt-* -Rf 9 | -------------------------------------------------------------------------------- /vagrant/scripts/pacman.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | /usr/bin/pacman-db-upgrade 6 | /usr/bin/sync 7 | /usr/bin/pacman -Syu -------------------------------------------------------------------------------- /vagrant/scripts/update.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # This script will update the build iso and checksum for black arch 3 | YEAR=$(date +%Y) 4 | MONTH=$(date +%m) 5 | 6 | 7 | function set_checksum() 8 | { 9 | MD5SUM=$(curl --silent https://mirror.rackspace.com/archlinux/iso/${YEAR}.${MONTH}.01/md5sums.txt | grep archlinux-${YEAR}.${MONTH}.01-x86_64.iso | awk ' { print $1 } ') 10 | echo "updating checksum" 11 | sed -i "s/\"iso_checksum\": \"[a-z0-9].*/\"iso_checksum\": \"$MD5SUM\",/g" template.json 12 | } 13 | 14 | function set_iso_file() 15 | { 16 | if curl -s --output /dev/null --silent --head --fail "https://mirror.rackspace.com/archlinux/iso/${YEAR}.${MONTH}.01/archlinux-${YEAR}.${MONTH}.01-x86_64.iso"; then 17 | echo "updating URL" 18 | sed -i "s;\"iso_url\": \"http.*\",$;\"iso_url\": \"https://mirror.rackspace.com/archlinux/iso/${YEAR}.${MONTH}.01/archlinux-${YEAR}.${MONTH}.01-x86_64.iso\",;g" template.json 19 | set_checksum 20 | return 0 21 | else 22 | if ${MONTH} -eq 1; then 23 | MONTH=12 24 | $((YEAR--)) 25 | else 26 | $((MONTH--)) 27 | fi 28 | set_iso_file 29 | fi 30 | } 31 | set_iso_file 32 | -------------------------------------------------------------------------------- /vagrant/scripts/vagrant.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | /usr/bin/mkdir -pm 700 /home/vagrant/.ssh 6 | /usr/bin/curl -k --output /home/vagrant/.ssh/authorized_keys --location https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub 7 | /usr/bin/chmod 0600 /home/vagrant/.ssh/authorized_keys 8 | /usr/bin/chown -R vagrant /home/vagrant/.ssh -------------------------------------------------------------------------------- /vagrant/scripts/virtualbox.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | DISK='/dev/sda' 6 | FQDN='blackarch.vm' 7 | KEYMAP='us' 8 | LANGUAGE='en_US.UTF-8' 9 | PASSWORD=$(/usr/bin/openssl passwd -crypt 'vagrant') 10 | Green='\e[0;32m' 11 | Reset='\e[0m' 12 | 13 | function msg () 14 | { 15 | echo -e "${Green}[+] $*${Reset}" 16 | } 17 | 18 | CONFIG_SCRIPT='/usr/local/bin/arch-config.sh' 19 | ROOT_PARTITION="${DISK}1" 20 | TARGET_DIR='/mnt' 21 | 22 | msg "clearing partition table on ${DISK}" 23 | /usr/bin/sgdisk --zap ${DISK} 24 | 25 | msg "destroying magic strings and signatures on ${DISK}" 26 | /usr/bin/dd if=/dev/zero of=${DISK} bs=512 count=2048 27 | /usr/bin/wipefs --all ${DISK} 28 | 29 | msg "creating /root partition on ${DISK}" 30 | /usr/bin/sgdisk --new=1:0:0 ${DISK} 31 | 32 | msg "setting ${DISK} bootable" 33 | /usr/bin/sgdisk ${DISK} --attributes=1:set:2 34 | 35 | msg "creating /root filesystem (ext4)" 36 | # https://www.youtube.com/watch?v=isHYr-5VH-Q 37 | /usr/bin/mkfs.ext4 -O '^64bit' -m 0 -F -L root ${ROOT_PARTITION} 38 | 39 | msg "mounting ${ROOT_PARTITION} to ${TARGET_DIR}" 40 | /usr/bin/mount -o noatime,errors=remount-ro ${ROOT_PARTITION} ${TARGET_DIR} 41 | 42 | msg "bootstrapping base installation" 43 | /usr/bin/pacstrap ${TARGET_DIR} base base-devel 44 | /usr/bin/arch-chroot ${TARGET_DIR} pacman -S --noconfirm gptfdisk openssh syslinux 45 | 46 | msg "configuring and installing syslinux" 47 | /usr/bin/arch-chroot ${TARGET_DIR} syslinux-install_update -i -a -m 48 | /usr/bin/sed -i 's/sda3/sda1/' "${TARGET_DIR}/boot/syslinux/syslinux.cfg" 49 | /usr/bin/sed -i 's/TIMEOUT 50/TIMEOUT 10/' "${TARGET_DIR}/boot/syslinux/syslinux.cfg" 50 | 51 | msg "generating the filesystem table" 52 | /usr/bin/genfstab -p ${TARGET_DIR} >> "${TARGET_DIR}/etc/fstab" 53 | 54 | msg "generating the system configuration script" 55 | /usr/bin/install --mode=0755 /dev/null "${TARGET_DIR}${CONFIG_SCRIPT}" 56 | 57 | cat <<-EOF > "${TARGET_DIR}${CONFIG_SCRIPT}" 58 | #!/usr/bin/env bash 59 | 60 | set -e 61 | 62 | echo '${FQDN}' > /etc/hostname 63 | /usr/bin/hwclock --systohc --utc 64 | echo 'KEYMAP=${KEYMAP}' > /etc/vconsole.conf 65 | /usr/bin/sed -i 's/#${LANGUAGE}/${LANGUAGE}/' /etc/locale.gen 66 | /usr/bin/locale-gen 67 | echo 'LANG=${LANGUAGE}' > /etc/locale.conf 68 | /usr/bin/mkinitcpio -p linux 69 | /usr/bin/usermod --password ${PASSWORD} root 70 | 71 | # https://wiki.archlinux.org/index.php/Network_Configuration#Device_names 72 | /usr/bin/ln -s /dev/null /etc/udev/rules.d/80-net-setup-link.rules 73 | /usr/bin/ln -s '/usr/lib/systemd/system/dhcpcd@.service' '/etc/systemd/system/multi-user.target.wants/dhcpcd@eth0.service' 74 | /usr/bin/sed -i 's/#UseDNS yes/UseDNS no/g' /etc/ssh/sshd_config 75 | /usr/bin/sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/g' /etc/ssh/sshd_config 76 | /usr/bin/systemctl enable sshd.service 77 | 78 | # VirtualBox Guest Additions 79 | /usr/bin/pacman -S --noconfirm virtualbox-guest-modules-arch 80 | /usr/bin/pacman -S --noconfirm virtualbox-guest-utils-nox 81 | 82 | # Vagrant-specific configuration 83 | /usr/bin/groupadd vagrant 84 | /usr/bin/useradd --password ${PASSWORD} --comment 'Vagrant User' --create-home --gid users --groups vagrant vagrant 85 | echo 'Defaults env_keep += "SSH_AUTH_SOCK"' > /etc/sudoers.d/10_vagrant 86 | echo 'vagrant ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers.d/10_vagrant 87 | /usr/bin/chmod 0440 /etc/sudoers.d/10_vagrant 88 | EOF 89 | 90 | msg "entering chroot and configuring system" 91 | /usr/bin/arch-chroot ${TARGET_DIR} ${CONFIG_SCRIPT} 92 | rm "${TARGET_DIR}${CONFIG_SCRIPT}" 93 | 94 | msg "installation complete!" 95 | /usr/bin/sleep 3 96 | /usr/bin/sync 97 | /usr/bin/umount ${TARGET_DIR} 98 | /usr/bin/systemctl reboot 99 | -------------------------------------------------------------------------------- /vagrant/scripts/yaourt.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | cat >> /etc/pacman.conf <", 6 | "/usr/bin/curl -O http://{{.HTTPIP}}:{{.HTTPPort}}/scripts/virtualbox.sh", 7 | "/usr/bin/bash ./virtualbox.sh" 8 | ], 9 | "boot_wait": "5s", 10 | "disk_size": 20480, 11 | "guest_additions_mode": "disable", 12 | "guest_os_type": "ArchLinux_64", 13 | "hard_drive_interface": "sata", 14 | "headless": true, 15 | "http_directory": ".", 16 | "output_directory": "output", 17 | "iso_checksum": "{{user `iso_checksum`}}", 18 | "iso_checksum_type": "{{user `iso_checksum_type`}}", 19 | "iso_url": "{{user `iso_url`}}", 20 | "shutdown_command": "sudo poweroff", 21 | "ssh_password": "vagrant", 22 | "ssh_username": "vagrant", 23 | "ssh_wait_timeout": "10000s", 24 | "type": "virtualbox-iso", 25 | "vboxmanage": [ 26 | [ 27 | "modifyvm", 28 | "{{.Name}}", 29 | "--memory", 30 | "{{user `memory`}}" 31 | ], 32 | [ 33 | "modifyvm", 34 | "{{.Name}}", 35 | "--cpus", 36 | "{{user `cpus`}}" 37 | ], 38 | [ 39 | "modifyvm", 40 | "{{.Name}}", 41 | "--rtcuseutc", 42 | "on" 43 | ] 44 | ], 45 | "virtualbox_version_file": ".vbox_version" 46 | } 47 | ], 48 | "post-processors": [ 49 | [ 50 | { 51 | "keep_input_artifact": true, 52 | "output": "output/blackarch_{{.Provider}}.box", 53 | "type": "vagrant" 54 | } 55 | ] 56 | ], 57 | "provisioners": [ 58 | { 59 | "override": { 60 | "virtualbox-iso": { 61 | "execute_command": "echo 'vagrant'|sudo -S bash '{{.Path}}'" 62 | } 63 | }, 64 | "scripts": [ 65 | "scripts/pacman.sh", 66 | "scripts/yaourt.sh", 67 | "scripts/zsh.sh", 68 | "scripts/vagrant.sh", 69 | "scripts/blackarch.sh", 70 | "scripts/cleanup.sh", 71 | "scripts/zerodisk.sh" 72 | ], 73 | "type": "shell" 74 | } 75 | ], 76 | "variables": { 77 | "cpus": "1", 78 | "iso_checksum": "4ae0f581e0ca27ba3a06646cad829b438d0b7e37433ee41d24d93dbb255669e2", 79 | "iso_checksum_type": "md5", 80 | "iso_url": "http://mirror.rackspace.com/archlinux/iso/2017.10.01/archlinux-2017.10.01-x86_64.iso", 81 | "memory": "1024" 82 | } 83 | } 84 | 85 | --------------------------------------------------------------------------------