-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Arkady Emeleyanov
committed
Nov 13, 2016
1 parent
d7f9213
commit 3f4adb7
Showing
5 changed files
with
193 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
{ | ||
"variables": { | ||
"ssh_name": "root", | ||
"ssh_pass": "alpine" | ||
}, | ||
|
||
"builders": [ | ||
{ | ||
"name": "alpine346", | ||
"type": "virtualbox-iso", | ||
"virtualbox_version_file": ".vbox_version", | ||
"headless": false, | ||
|
||
"guest_os_type": "Linux_64", | ||
"disk_size": 10240, | ||
"hard_drive_interface": "sata", | ||
|
||
"iso_url": "http://wiki.alpinelinux.org/cgi-bin/dl.cgi/v3.4/releases/x86_64/alpine-3.4.6-x86_64.iso", | ||
"iso_checksum": "bb29d5360e5369a1a64cf681bfa7e93ce7adc4ab", | ||
"iso_checksum_type": "sha1", | ||
|
||
"boot_wait": "20s", | ||
"boot_command": [ | ||
"root<enter><wait>", | ||
"ifconfig eth0 up && udhcpc -i eth0<enter><wait5>", | ||
"wget http://{{ .HTTPIP }}:{{ .HTTPPort }}/alpine346/kickstart.cfg<enter><wait>", | ||
"setup-alpine -f kickstart.cfg<enter><wait5>", | ||
"alpine<enter><wait>", | ||
"alpine<enter><wait>", | ||
"<wait10><wait10><wait10>", | ||
"<wait10><wait10>", | ||
"y<enter>", | ||
"<wait10><wait10><wait10>", | ||
"<wait10><wait10><wait10>", | ||
"<wait10><wait10>", | ||
"rc-service sshd stop<enter><wait>", | ||
"mount /dev/sda3 /mnt<enter>", | ||
"echo 'PermitRootLogin yes' >> /mnt/etc/ssh/sshd_config<enter>", | ||
"umount /mnt<enter>", | ||
"reboot<enter>" | ||
], | ||
"http_directory": "http", | ||
"guest_additions_path": "/root/VBoxGuestAdditions_{{.Version}}.iso", | ||
|
||
"ssh_username": "{{user `ssh_name`}}", | ||
"ssh_password": "{{user `ssh_pass`}}", | ||
|
||
"vboxmanage": [ | ||
["modifyvm", "{{.Name}}", "--memory", "512"], | ||
["modifyvm", "{{.Name}}", "--cpus", "1"] | ||
], | ||
|
||
"shutdown_command": "/sbin/poweroff" | ||
} | ||
], | ||
|
||
"post-processors": [{ | ||
"output": "build/dalee-alpine.box", | ||
"type": "vagrant", | ||
"compression_level": 7 | ||
}], | ||
|
||
"provisioners": [{ | ||
"type": "shell", | ||
"execute_command": "/bin/sh -x '{{.Path}}'", | ||
"scripts": [ | ||
"scripts/alpine346/vagrant.sh", | ||
"scripts/alpine346/vboxguest.sh", | ||
"scripts/alpine346/compact.sh" | ||
] | ||
}] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
KEYMAPOPTS="us us" | ||
HOSTNAMEOPTS="-n alpine" | ||
INTERFACESOPTS="auto lo | ||
iface lo inet loopback | ||
auto eth0 | ||
iface eth0 inet dhcp | ||
" | ||
DNSOPTS="-d local" | ||
TIMEZONEOPTS="-z Europe/Moscow" | ||
PROXYOPTS="none" | ||
APKREPOSOPTS="http://dl-cdn.alpinelinux.org/alpine/v3.4/main" | ||
SSHDOPTS="-c openssh" | ||
NTPOPTS="-c none" | ||
DISKOPTS="-s 0 -m sys /dev/sda" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/usr/bin/env bash | ||
|
||
echo "Compacting hard-drive, could take few minutes" | ||
dd if=/dev/zero of=/junk bs=1M | ||
rm -f /junk | ||
|
||
sync |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/env bash | ||
|
||
# upgrade system | ||
apk update | ||
apk upgrade --no-self-upgrade --available | ||
apk add sudo bash curl wget | ||
|
||
# add vagrant user | ||
adduser -D vagrant | ||
echo 'vagrant:vagrant' | chpasswd | ||
|
||
# install vagrant insecure key, it will be replaced during initial "vagrant up" | ||
echo "" > /etc/motd | ||
echo "vagrant ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/vagrant | ||
echo "Defaults:vagrant !requiretty" >> /etc/sudoers.d/vagrant | ||
sed 's/\/bin\/ash/\/bin\/bash/g' -i /etc/passwd | ||
|
||
mkdir -pm 700 /home/vagrant/.ssh | ||
curl -sSo /home/vagrant/.ssh/authorized_keys "https://raw.githubusercontent.com/mitchellh/vagrant/master/keys/vagrant.pub" | ||
chown -R vagrant:vagrant /home/vagrant/.ssh | ||
chmod -R go-rwsx /home/vagrant/.ssh | ||
|
||
# add shutdown command for vagrant | ||
echo -e '#!/usr/bin/env bash\n/sbin/poweroff' > /sbin/shutdown | ||
chmod +x /sbin/shutdown |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -eo pipefail | ||
|
||
VERSION=$(cat /root/.vbox_version) | ||
|
||
mkdir -p /tmp/cdrom | ||
modprobe loop | ||
LOOP=`losetup -f` | ||
losetup ${LOOP} /root/VBoxGuestAdditions_$VERSION.iso | ||
mount -t iso9660 -o ro ${LOOP} /tmp/cdrom | ||
|
||
# install required software | ||
apk add make gcc g++ musl-dev libc-dev linux-headers linux-grsec-dev | ||
|
||
# initial extract of vbox additionals | ||
if [ -d /root/install ]; then | ||
rm -rf /root/install | ||
fi | ||
mkdir /root/install | ||
echo "af_packet" > /etc/modules | ||
|
||
# copy base source | ||
cp /tmp/cdrom/VBoxLinuxAdditions.run /root/install/vbox-add.run | ||
chmod +x /root/install/vbox-add.run | ||
/root/install/vbox-add.run --noexec --keep --target /root/install/vbox-add | ||
|
||
# unpacking sources | ||
mkdir -p /root/install/vbox-add-src | ||
tar jxfv /root/install/vbox-add/VBoxGuestAdditions-amd64.tar.bz2 -C /root/install/vbox-add-src | ||
cd /root/install/vbox-add-src/src/vboxguest-${VERSION} | ||
make | ||
cp ./*.ko /lib/modules/`uname -r` | ||
echo "vboxguest" >> /etc/modules | ||
echo "vboxsf" >> /etc/modules | ||
|
||
# download whole vbox project | ||
curl "http://download.virtualbox.org/virtualbox/${VERSION}/VirtualBox-${VERSION}.tar.bz2" -o /root/install/vbox-src.tar.bz2 | ||
mkdir -p /root/install/vbox-src | ||
tar jxfv /root/install/vbox-src.tar.bz2 -C /root/install/vbox-src | ||
|
||
cd /root/install/vbox-src/VirtualBox-${VERSION}/src/VBox/Additions/linux/sharedfolders | ||
gcc ./mount.vboxsf.c ./vbsfmount.c -o mount.vboxsf \ | ||
-I/root/install/vbox-src/VirtualBox-${VERSION}/include \ | ||
-I/usr/src/linux-headers-`uname -r`/include \ | ||
-D__gnu_linux__ -DIN_RING3 | ||
|
||
cp ./mount.vboxsf /usr/sbin | ||
|
||
# cleanup | ||
rm -rf /root/install | ||
rm -rf /root/*.iso | ||
|
||
# cleanup everything except make | ||
apk del --purge \ | ||
gcc \ | ||
g++ \ | ||
binutils-libs \ | ||
binutils \ | ||
gmp \ | ||
isl \ | ||
libgomp \ | ||
libatomic \ | ||
libgcc \ | ||
pkgconf \ | ||
pkgconfig \ | ||
mpfr3 \ | ||
mpc1 \ | ||
libstdc++ \ | ||
libgmpxx \ | ||
gmp-dev \ | ||
linux-headers \ | ||
musl-dev libc-dev \ | ||
linux-grsec-dev |