pine64-slackware/make_usd_card.sh

89 lines
2.8 KiB
Bash
Raw Normal View History

#!/bin/sh
# inspired by https://github.com/umiddelb/z2d/tree/master/pine64
display_usage() {
echo "$0 </dev/mmcblk0> </mnt/SD>"
}
SD_DEV=$1
SD_MOUNT_POINT=$2
[ "x$1" == "x" ] && display_usage && exit
[ "x$2" == "x" ] && display_usage && exit
2016-07-13 07:30:11 +02:00
[[ "x$UID" != "x0" ]] && echo "run as root" && exit
2016-07-13 07:13:40 +02:00
2016-07-13 07:11:06 +02:00
if $(df | grep /$ | grep -q "^$SD_DEV"); then
echo "Target and current system device are the same. Can't do that!"
exit
fi
2016-07-17 17:55:12 +02:00
CWD=$(pwd)
2016-07-12 18:32:22 +02:00
SIMPLEIMAGE_VERSION=${SIMPLEIMAGE_VERSION:-"latest"}
LINUX_VERSION=${LINUX_VERSION:-"latest"}
2016-09-25 17:15:24 +02:00
SLACKWARE_VERSION=${SLACKWARE_VERSION:-"current"}
2018-09-09 16:44:44 +02:00
SLACKWARE_MINIROOTFS_VERSION=${SLACKWARE_MINIROOTFS_VERSION:-"30Aug18"}
2018-09-09 16:45:14 +02:00
SSH_PUB_KEY=${SSH_PUB_KEY:-~/.ssh/id_ed25519.pub}
2016-07-12 18:32:22 +02:00
2016-07-13 07:11:06 +02:00
echo "Going further will wipe ${SD_DEV} and you _will_ lose all data on it !"
echo "/!\\ LAST CHANCE TO HIT Ctrl-C /!\\"
read
2016-07-12 18:32:22 +02:00
wget -c https://www.stdin.xyz/downloads/people/longsleep/pine64-images/simpleimage-pine64-${SIMPLEIMAGE_VERSION}.img.xz
unxz simpleimage-pine64-${SIMPLEIMAGE_VERSION}.img.xz
dd if=simpleimage-pine64-${SIMPLEIMAGE_VERSION}.img of=$SD_DEV bs=1024
/bin/echo -e "d\n2\nn\np\n2\n143360\n\nw\n" | sudo fdisk $SD_DEV
sudo mkfs.ext4 -O ^has_journal -b 4096 -L rootfs -U deadbeef-dead-beef-dead-beefdeadbeef ${SD_DEV}p2
mount ${SD_DEV}p2 $SD_MOUNT_POINT
mkdir -p $SD_MOUNT_POINT/bootenv
mount ${SD_DEV}p1 $SD_MOUNT_POINT/bootenv
2016-09-25 17:15:15 +02:00
wget -c http://ftp.arm.slackware.com/slackwarearm/slackwarearm-devtools/minirootfs/roots/slack-${SLACKWARE_VERSION}-miniroot_${SLACKWARE_MINIROOTFS_VERSION}.tar.xz
2016-07-12 18:32:22 +02:00
tar --numeric-owner -C $SD_MOUNT_POINT/ -xpJf slack-${SLACKWARE_VERSION}-miniroot_${SLACKWARE_MINIROOTFS_VERSION}.tar.xz
2016-07-12 18:32:22 +02:00
wget -c https://www.stdin.xyz/downloads/people/longsleep/pine64-images/linux/linux-pine64-${LINUX_VERSION}.tar.xz
tar --numeric-owner -C $SD_MOUNT_POINT/ -xpJf linux-pine64-${LINUX_VERSION}.tar.xz
cp -R $SD_MOUNT_POINT/boot/* $SD_MOUNT_POINT/bootenv/
2016-07-12 19:30:17 +02:00
cat <<EOF > $SD_MOUNT_POINT/etc/modprobe.d/blacklist
8723bs_vq0
EOF
cat <<EOF >> $SD_MOUNT_POINT/etc/rc.d/rc.modprobe.local
/sbin/modprobe 8723bs
EOF
2016-07-17 17:28:47 +02:00
cat <<EOF >> $SD_MOUNT_POINT/etc/fstab
/dev/mmcblk0p2 / ext4 defaults,discard 1 1
tmpfs /tmp tmpfs defaults,mode=777 0 0
EOF
2016-09-30 19:27:20 +02:00
cat <<EOF > $SD_MOUNT_POINT/etc/motd
____ _ __ _ _
| _ \(_)_ __ ___ / /_ | || |
| |_) | | '_ \ / _ \ '_ \| || |_
| __/| | | | | __/ (_) |__ _|
|_| |_|_| |_|\___|\___/ |_|
Slackware
EOF
2016-07-17 17:55:12 +02:00
cp $CWD/pine64-kernel.SlackBuild $SD_MOUNT_POINT/root
2018-09-09 16:45:14 +02:00
mkdir -p $SD_MOUNT_POINT/root/.ssh/
cp $SSH_PUB_KEY $SD_MOUNT_POINT/root/.ssh/authorized_keys
umount $SD_MOUNT_POINT/bootenv
umount $SD_MOUNT_POINT
2016-07-13 07:31:21 +02:00
sync
2016-09-25 17:15:15 +02:00
curl -s http://ftp.arm.slackware.com/slackwarearm/slackwarearm-devtools/minirootfs/roots/slack-${SLACKWARE_VERSION}-miniroot_details.txt | grep -C1 "User"
2016-07-13 07:30:11 +02:00
2016-07-13 07:31:21 +02:00
echo "All done, eject your microSD card, insert it in the Pine64 and boot it :)"