archiso-zfs/init

57 lines
1.2 KiB
Plaintext
Raw Normal View History

2020-05-01 16:19:33 +02:00
#!/bin/bash
# This script load zfs kernel module for any archiso.
# github.com/eoli3n
2020-05-05 22:25:47 +02:00
# Thanks to CalimeroTeknik on #archlinux-fr, FFY00 on #archlinux-projects, JohnDoe2 on #regex
2020-05-01 16:19:33 +02:00
set -e
print () {
echo -e "\n\033[1m> $1\033[0m\n"
}
2020-05-01 18:34:14 +02:00
print "Testing if archiso is running"
2020-05-01 16:19:33 +02:00
grep archiso /proc/cmdline
2020-05-05 22:25:47 +02:00
print "Increasing cowspace to half of RAM"
mount -o remount,size=50% /run/archiso/cowspace
2020-05-05 21:01:07 +02:00
print "Install zfs module"
2020-05-01 16:19:33 +02:00
2020-05-05 22:25:47 +02:00
# Get running kernel version
kernel_version=$(pacman -Qi linux | sed -n 's/^Version\s*: //p')
2020-05-01 16:19:33 +02:00
2020-05-05 22:25:47 +02:00
# Set regex to match package
regex='href="\Kzfs-linux-[0-9].*?'"$kernel_version"'.*?(?!.+\.sig)x86_64[^\"]+'
2020-05-01 16:19:33 +02:00
2020-05-05 22:25:47 +02:00
# Search kernel on archzfs repos
urls="http://archzfs.com/archzfs/x86_64/ http://archzfs.com/archive_archzfs/"
# Loop search
for url in $urls
do
# Query url and try to match package
package=$(curl -s "$url" | grep -Po "$regex")
# If a package is found
if [[ ! -z $package ]]
then
# Build package url
package_url="$url$package"
print "Installing package $package..."
pacman -U "$package_url"
# Break loop
break
fi
done
2020-05-01 16:19:33 +02:00
2020-05-01 18:34:14 +02:00
print "Loading zfs kernel module"
2020-05-01 16:19:33 +02:00
modprobe zfs
2020-05-01 18:34:14 +02:00
print "ZFS module is working"