...
 
Commits (11)
image: debian:latest
build:
stage: build
before_script:
- apt-get update -y
- DEBIAN_FRONTEND=noninteractive apt-get -o Acquire::Retires=10 install --no-install-recommends -qq libguestfs-tools busybox linux-image-amd64 gnupg1 openssh-client
- ssh-keygen -q -N '' -f ~/.ssh/id_rsa
script:
- 'LIBGUESTFS_BACKEND=direct virt-builder --gpg /usr/bin/gpg1 --arch x86_64 debian-9 -o debian.raw --root-password password:root --ssh-inject root --install wget,ca-certificates --firstboot-command "dpkg-reconfigure openssh-server"'
after_script:
- mv ~/.ssh/id_rsa id_rsa
cache:
paths:
- debian.raw
- id_rsa
policy: push
.tests:
retry: 1
stage: test
before_script:
- apt-get update -y
- DEBIAN_FRONTEND=noninteractive apt-get -o Acquire::Retires=10 install --no-install-recommends -qq qemu-system-x86 openssh-client sshpass
- mkdir ~/.ssh
- mv id_rsa ~/.ssh/id_rsa
- printf '%s\n\t' 'Host *' 'ServerAliveInterval 15' 'UserKnownHostsFile /dev/null' 'StrictHostKeyChecking no' 'CheckHostIP no' > ~/.ssh/config
- qemu-system-x86_64 -m 256 -daemonize -drive file=debian.raw,if=virtio -net nic -net user,hostfwd=tcp::10022-:22 -display none -vga none
- sleep 60
- scp -P 10022 vps2arch root@127.0.0.1:vps2arch
- ssh -p 10022 root@127.0.0.1 "chmod +x vps2arch"
dependencies:
- build
cache:
paths:
- debian.raw
- id_rsa
policy: pull
test_default:
extends: .tests
script:
- 'ssh -p 10022 root@127.0.0.1 "./vps2arch && sync ; reboot -f" || true'
- sleep 600
- sshpass -proot ssh -p 10022 root@127.0.0.1 test -f /etc/arch-release
test_netctl:
extends: .tests
script:
- 'ssh -p 10022 root@127.0.0.1 "./vps2arch -n netctl && sync ; reboot -f" || true'
- sleep 600
- sshpass -proot ssh -p 10022 root@127.0.0.1 test -f /etc/arch-release
test_syslinux:
extends: .tests
script:
- 'ssh -p 10022 root@127.0.0.1 "./vps2arch -b syslinux && sync ; reboot -f" || true'
- sleep 600
- sshpass -proot ssh -p 10022 root@127.0.0.1 test -f /etc/arch-release
......@@ -6,7 +6,7 @@ The fastest way to convert a _VPS_ to [Arch Linux](https://www.archlinux.org/)!
Author
------
[Timothy Redaelli](mailto:tredaelli@archlinux.info)
[Timothy Redaelli](mailto:timothy@fsfe.org)
Description
-----------
......@@ -27,14 +27,14 @@ Download the script on your _VPS_ and execute it with root privileges
**WARNING** The script will **delete** any data in your _VPS_!
wget http://git.io/vps2arch
wget http://tinyurl.com/vps2arch
chmod +x vps2arch
./vps2arch
Some _Debian_ _VPS_ images don't have the _CA certificates_ installed, so `wget` will give you the following errors:
ERROR: The certificate of `raw.githubusercontent.com' is not trusted.
ERROR: The certificate of `raw.githubusercontent.com' hasn't got a known issuer.
ERROR: The certificate of `gitlab.com' is not trusted.
ERROR: The certificate of `gitlab.com' hasn't got a known issuer.
To fix them just execute `apt-get install ca-certificates` and then re-execute the previous commands.
......@@ -66,7 +66,7 @@ Does it really work?
Yes, it does!
On the [Tested VPS Providers](https://github.com/drizzt/vps2arch/wiki/Tested-VPS-Providers) wiki page you can find a list of **Tested VPS Providers**.
On the [Tested VPS Providers](https://gitlab.com/drizzt/vps2arch/wikis/Tested-VPS-Providers) wiki page you can find a list of **Tested VPS Providers**.
Theoretically it should also work on **real** computers (running linux), but I think it's not worth it,
because you can install it in the canonical way.
......
......@@ -25,9 +25,15 @@ else
exit 2
fi
get_worldwide_mirrors() {
echo "http://mirrors.kernel.org/archlinux"
_download 'https://www.archlinux.org/mirrorlist/?country=all&protocol=http&protocol=https&ip_version=4' | awk '/^## /{if ($2 == "Worldwide") { flag=1 } else { flag=0 } } /^#Server/ { if (flag) { sub(/\/\$repo.*/, ""); print $3 } }'
}
cpu_type=$(uname -m)
is_openvz() { [ -d /proc/vz -a ! -d /proc/bc ]; }
is_lxc() { grep -aqw container=lxc /proc/1/environ ; }
download() {
local path="$1" x=
......@@ -84,7 +90,7 @@ configure_chroot() {
mv "/root.$cpu_type/etc/pacman.conf.bak" "/root.$cpu_type/etc/pacman.conf"
fi
chroot_exec 'pacman-key --init && pacman-key --populate archlinux'
chroot_exec 'pacman --noconfirm -Sy awk'
# Generate fstab
chroot_exec 'genfstab /mnt >> /etc/fstab'
......@@ -156,22 +162,25 @@ configure_bootloader() {
grep -q '^[[:space:]]*eth' /proc/net/dev && \
sed -i.bak 's/GRUB_CMDLINE_LINUX_DEFAULT="/&net.ifnames=0 /' /etc/default/grub
# Disable "graphic" terminal output
sed -i.bak 's/^#GRUB_TERMINAL_OUTPUT=console/GRUB_TERMINAL_OUTPUT=console/' /etc/default/grub
if [ $needs_lvm2 -eq 1 ]; then
local vg
vg=$(lvs --noheadings $root_dev | awk '{print $2}')
root_dev=$(pvs --noheadings | awk -v vg="$vg" '($2 == vg) { print $1 }')
fi
for root_dev in $root_dev; do
tmp=$(lsblk -npsro NAME "$root_dev" | tail -n1)
tmp=$(lsblk -npsro TYPE,NAME "$root_dev" | awk '($1 == "disk") { print $2}')
case " $root_devs " in
*" $tmp "*) ;;
*) root_devs="${root_devs:+$root_devs }$tmp" ;;
esac
done
grub-mkconfig > /boot/grub/grub.cfg
for root_dev in $root_devs; do
grub-install --target=i386-pc --recheck --force "$root_dev"
done
grub-mkconfig > /boot/grub/grub.cfg
elif [ "$bootloader" = "syslinux" ]; then
# If you are still using eth* as interface name, disable "strange" ifnames
grep -q '^[[:space:]]*eth' /proc/net/dev && tmp="net.ifnames=0"
......@@ -321,11 +330,14 @@ while getopts ":b:m:n:h" opt; do
done
shift $((OPTIND - 1))
: ${mirrors:="http://mirror.rackspace.com/archlinux http://dgix.ru/mirrors/archlinux"}
[ -z "$mirrors" ] && mirrors=$(get_worldwide_mirrors)
if is_openvz; then
bootloader=none
network=netctl
elif is_lxc; then
bootloader=none
fi
cd /
......