ungleich-tools/openwrt/openwrt-add-usb-storage-stick.sh
2021-11-16 14:29:46 +01:00

28 lines
605 B
Bash
Executable file

#!/bin/sh
# Nico Schottelius
# 2021-01-07
# Based on https://openwrt.org/docs/guide-user/storage/usb-drives-quickstart
if [ $# -ne 1 ]; then
echo "$0 ip-address nat64-prefix"
echo " ip-address: where to find the OpenWRT device"
exit 1
fi
my_ip=$1; shift
cat <<EOF | ssh -t "root@${my_ip}"
set -x
opkg update
opkg install block-mount e2fsprogs kmod-fs-ext4 kmod-usb-storage kmod-usb2 kmod-usb3
echo y | mkfs.ext4 /dev/sda1
block detect | uci import fstab
uci set fstab.@mount[0].enabled='1' && uci set fstab.@global[0].anon_mount='1' && uci commit fstab
/etc/init.d/fstab boot
EOF