switch to nfs over ssh, use data.json only, update todo

This commit is contained in:
askiiart 2025-06-18 00:39:14 -05:00
parent 5cafab577d
commit 09b00300f6
Signed by untrusted user who does not match committer: askiiart
GPG key ID: 6A32977DAF31746A
5 changed files with 34 additions and 43 deletions

View file

@ -29,21 +29,22 @@ fi
# add rpool disks
for id in $(jq ."disks"."other"[]? $SCRIPT_DIR/data.json -r); do
disk=$(readlink -f /dev/disk/by-id/$id)
if ! $(zpool status rpool | grep -q "${disk##*/}"); then
zpool add rpool $disk
if ! $(zpool status rpool | grep -q "$id"); then
zpool add rpool $id
else
echo $disk already added to pool, skipping
echo $id already added to pool, skipping
fi
done
### Other disk setup ###
mkdir -p /mnt/media{0,1,2,3} /mnt/cache /mnt/media
while read line; do
if ! grep -q "$line" /etc/fstab; then
echo "$line" | tee -a /etc/fstab
IFS=$'\n'
for key in $(jq '."fstab"[]?' $SCRIPT_DIR/data.json -r); do
if ! grep -q "$key" /etc/fstab; then
echo "$key" | tee -a /etc/fstab
fi
done <$SCRIPT_DIR/fstab
done
unset IFS
mount -a || true
read -p "If it's safe to continue, press enter. Otherwise, do ^C to exit."
systemctl daemon-reload
@ -54,27 +55,22 @@ apt install $(jq ."programs"[]? $SCRIPT_DIR/data.json -r | tr '\n' ' ') -y
sed -i 's/#PasswordAuthentication yes/PasswordAuthentication no/g' /etc/ssh/sshd_config
sed -i 's/#Port 22/Port 2222/g' /etc/ssh/sshd_config
### SMB - Share to the server ###
apt install samba -y
### NFS ###
apt install nfs-kernel-server -y
while read line; do
if ! grep -q "$line" /etc/samba/smb.conf; then
echo "$line" | tee -a /etc/samba/smb.conf
IFS=$'\n'
for key in $(jq '."exports"[]?' $SCRIPT_DIR/data.json -r); do
if ! grep -q "$key" /etc/exports; then
echo "$key" | tee -a /etc/exports
fi
done <$SCRIPT_DIR/smb.conf
systemctl restart smbd
# ASSUMES USER IS ROOT
# ASSUMES SMB SHOULD BE ROOT
smb_user="root"
if ! $(pdbedit -L -v | grep -q "Unix username: .*$smb_user"); then
read -p "Enter the SMB password at the prompt - press enter to continue"
smbpasswd -a $smb_user
fi
done
unset IFS
systemctl enable --now nfs-kernel-server
IFS=$'\n'
for key in $(jq '."ssh-keys"[]?' $SCRIPT_DIR/data.json -r); do
if ! grep -q "$key" $HOME/.ssh/authorized_keys; then
if ! grep -q "$key" $HOME/.ssh/authorized_keys; then
echo "$key" | tee -a $HOME/.ssh/authorized_keys
fi
done
unset IFS
unset IFS