mirror of
https://github.com/wickedyoda/public-setupfiles.git
synced 2026-11-16 13:31:56 -06:00
commit
1e25e36ce6
195 files changed
+152301
No files matched your search
@@ -0,0 +1,15 @@
|
||||
//nas/public /media/naspublic cifs vers=2.0,username=admin,password=(enterhere),file_mode=0777,dir_mode=0777,_netdev,auto 0 0
|
||||
//nas/DownloadedMedia /media/nasdownloadedmedia cifs vers=2.0,username=admin,password=(Enterhere),file_mode=0777,dir_mode=0777,_netdev,auto 0 0
|
||||
|
||||
# old
|
||||
//nas/public /home/traver/naspublic cifs vers=2.0,username=admin,password=(enterhere),file_mode=0777,dir_mode=0777,_netdev,auto 0 0
|
||||
//nas/DownloadedMedia /home/traver/nasdownloadedmedia cifs vers=2.0,username=admin,password=(Enterhere),file_mode=0777,dir_mode=0777,_netdev,auto 0 0
|
||||
|
||||
//nas/public /media/naspublic cifs vers=2.0,username=admin,password=$PASSWORD,file_mode=0777,dir_mode=0777,_netdev,auto 0 0
|
||||
//nas/DownloadedMedia /media/nasmedia cifs vers=2.0,username=admin,password=$PASSWORD,file_mode=0777,dir_mode=0777,_netdev,auto 0 0
|
||||
//nas/public-share2 /media/naspublic-share2 cifs vers=2.0,username=admin,password=$PASSWORD,file_mode=0777,dir_mode=0777,_netdev,auto 0 0
|
||||
|
||||
|
||||
//nas/public /mnt/naspublic cifs vers=2.0,username=admin,password=$PASSWORD,file_mode=0777,dir_mode=0777,_netdev,auto 0 0
|
||||
//nas/DownloadedMedia /mnt/nasmedia cifs vers=2.0,username=admin,password=$PASSWORD,file_mode=0777,dir_mode=0777,_netdev,auto 0 0
|
||||
//nas/public-share2 /mnt/naspublic-share2 cifs vers=2.0,username=admin,password=$PASSWORD,file_mode=0777,dir_mode=0777,_netdev,auto 0 0
|
||||
@@ -0,0 +1,44 @@
|
||||
<<<<<<< HEAD
|
||||
# fstab-setup
|
||||
|
||||
## Purpose
|
||||
This directory contains files related to **fstab setup**.
|
||||
|
||||
## Contents
|
||||
- `setup-fstab.sh`
|
||||
- `Fstab entries.txt`
|
||||
- `setup-fstab-remake-mnt.sh`
|
||||
|
||||
## Usage
|
||||
- Review each script or configuration file before running
|
||||
- Some scripts may require **root or sudo**
|
||||
- Paths and variables may need adjustment for your environment
|
||||
|
||||
## Notes
|
||||
- This folder is part of the **public-setupfiles** repository
|
||||
- Files are provided as-is for reference or automation
|
||||
|
||||
## Safety
|
||||
Always back up data before running scripts that modify system state.
|
||||
=======
|
||||
# fstab-setup
|
||||
|
||||
## Overview
|
||||
This directory is part of the **public-setupfiles** repository.
|
||||
It contains scripts, configuration files, or resources related to **fstab-setup**.
|
||||
|
||||
## Usage
|
||||
- Review scripts before execution
|
||||
- Some files may require **root or sudo privileges**
|
||||
- Paths, variables, or credentials may need customization
|
||||
|
||||
## Logging & Output
|
||||
Scripts may generate logs or output files in the same directory or system locations.
|
||||
|
||||
## Safety Notes
|
||||
- Always back up important data before running scripts
|
||||
- Test in a non-production environment when possible
|
||||
- Use at your own risk
|
||||
|
||||
---
|
||||
>>>>>>> main
|
||||
@@ -0,0 +1,48 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Define variables
|
||||
CREDENTIALS_FILE="/root/.smbcredentials"
|
||||
FSTAB_FILE="/etc/fstab"
|
||||
|
||||
# 1️⃣ Prompt for Username and Password
|
||||
read -p "Enter NAS Username: " NAS_USER
|
||||
read -s -p "Enter NAS Password: " NAS_PASS
|
||||
echo "" # Move to a new line after password entry
|
||||
|
||||
# 2️⃣ Install CIFS Utilities
|
||||
echo "🔹 Installing CIFS utilities..."
|
||||
sudo apt update && sudo apt install -y cifs-utils
|
||||
|
||||
# 3️⃣ Create Mount Points
|
||||
echo "🔹 Creating mount points..."
|
||||
sudo mkdir -p /mnt/naspublic /mnt/nasmedia /mnt/naspublic-share2
|
||||
|
||||
# 4️⃣ Securely Store Credentials
|
||||
echo "🔹 Creating SMB credentials file..."
|
||||
sudo bash -c "echo -e 'username=$NAS_USER\npassword=$NAS_PASS' > $CREDENTIALS_FILE"
|
||||
sudo chmod 600 "$CREDENTIALS_FILE"
|
||||
|
||||
# 5️⃣ Update fstab Entries
|
||||
echo "🔹 Updating /etc/fstab..."
|
||||
FSTAB_ENTRIES="
|
||||
//nas/Public /mnt/naspublic cifs credentials=$CREDENTIALS_FILE,vers=2.0,file_mode=0777,dir_mode=0777,_netdev,x-systemd.automount,nofail 0 0
|
||||
//nas/media /mnt/nasmedia cifs credentials=$CREDENTIALS_FILE,vers=2.0,file_mode=0777,dir_mode=0777,_netdev,x-systemd.automount,nofail 0 0
|
||||
//nas/public2 /mnt/naspublic-share2 cifs credentials=$CREDENTIALS_FILE,vers=2.0,file_mode=0777,dir_mode=0777,_netdev,x-systemd.automount,nofail 0 0
|
||||
"
|
||||
|
||||
if ! grep -q "//nas/Public" "$FSTAB_FILE"; then
|
||||
echo "$FSTAB_ENTRIES" | sudo tee -a "$FSTAB_FILE" > /dev/null
|
||||
echo "✅ fstab updated."
|
||||
else
|
||||
echo "✅ fstab entries already exist."
|
||||
fi
|
||||
|
||||
# 6️⃣ Apply the Mounts
|
||||
echo "🔹 Mounting all fstab entries..."
|
||||
sudo mount -a
|
||||
|
||||
# Verify if the shares are mounted
|
||||
echo "🔹 Checking mounted shares..."
|
||||
df -h | grep /mnt/nas
|
||||
|
||||
echo "✅ Setup complete!"
|
||||
@@ -0,0 +1,50 @@
|
||||
# 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."
|
||||
|
||||
|
||||
# installed needed package
|
||||
apt update
|
||||
apt-get -y install \
|
||||
samba-common-bin \
|
||||
smbclient \
|
||||
cifs-utils \
|
||||
exfat-fuse \
|
||||
curl \
|
||||
unattended-upgrades \
|
||||
cron-apt \
|
||||
git \
|
||||
curl
|
||||
|
||||
# Make directories
|
||||
cd /mnt
|
||||
mkdir nasmedia
|
||||
mkdir naspublic
|
||||
mkdir naspublic-share2
|
||||
|
||||
# Echo the command below into the file /etc/fstab
|
||||
echo '# NAS Public Share
|
||||
//nas/public /mnt/naspublic cifs credentials=/root/.smbcredentials,vers=3.0,file_mode=0777,dir_mode=0777,_netdev,x-systemd.automount,nofail 0 0
|
||||
|
||||
# NAS Media Share
|
||||
//nas/media /mnt/nasmedia cifs credentials=/root/.smbcredentials,vers=3.0,file_mode=0777,dir_mode=0777,_netdev,x-systemd.automount,nofail 0 0
|
||||
|
||||
# NAS Public2 Share
|
||||
//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
|
||||
|
||||
# Mount the file systems
|
||||
mount -a
|
||||
Reference in new issue
Block a user