Files
public-setupfiles/fstab-setup/setup-fstab.sh
T

50 lines
1.3 KiB
Bash
Raw Normal View History

2025-04-07 16:50:21 -05:00
# Set path for credentials file
CREDENTIALS_FILE="$HOME/.smbcredentials"
# Prompt for username and password
echo "Creating SMB credentials file at $CREDENTIALS_FILE"
read -p "Enter your SMB username: " SMB_USER
read -s -p "Enter your SMB password: " SMB_PASS
echo
# Write to .smbcredentials securely
cat <<EOF > "$CREDENTIALS_FILE"
username=$SMB_USER
password=$SMB_PASS
EOF
chmod 600 "$CREDENTIALS_FILE"
echo "Created credentials file with 600 permissions."
2024-03-31 15:27:09 -05:00
# installed needed package
2023-12-16 19:03:50 -06:00
apt update
apt-get -y install \
samba-common-bin \
smbclient \
cifs-utils \
exfat-fuse \
curl \
unattended-upgrades \
cron-apt \
git \
curl
# Make directories
2025-04-07 16:43:18 -05:00
cd /mnt
2023-12-16 19:03:50 -06:00
mkdir nasmedia
mkdir naspublic
2024-05-07 14:48:25 -05:00
mkdir naspublic-share2
2023-12-16 19:03:50 -06:00
# Echo the command below into the file /etc/fstab
2025-03-15 18:42:40 -05:00
echo '# NAS Public Share
2025-05-11 19:04:17 -05:00
//nas/public /mnt/naspublic cifs credentials=/root/.smbcredentials,vers=3.0,file_mode=0777,dir_mode=0777,_netdev,x-systemd.automount,nofail 0 0
2025-03-15 18:42:40 -05:00
# NAS Media Share
2025-05-11 19:04:17 -05:00
//nas/media /mnt/nasmedia cifs credentials=/root/.smbcredentials,vers=3.0,file_mode=0777,dir_mode=0777,_netdev,x-systemd.automount,nofail 0 0
2025-03-15 18:42:40 -05:00
# NAS Public2 Share
2025-05-11 19:04:17 -05:00
//nas/public2 /mnt/naspublic-share2 cifs credentials=/root/.smbcredentials,vers=3.0,file_mode=0777,dir_mode=0777,_netdev,x-systemd.automount,nofail 0 0' | sudo tee -a /etc/fstab
2023-12-16 19:03:50 -06:00
2024-03-31 15:27:09 -05:00
# Mount the file systems
mount -a