ps2_samba.sh aktualisiert
This commit is contained in:
parent
600a5aacc6
commit
52d2c5a867
1 changed files with 3 additions and 16 deletions
19
ps2_samba.sh
19
ps2_samba.sh
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# Get the current user (not root)
|
# Get the real user (not root)
|
||||||
REALUSER=$(logname)
|
REALUSER=$(logname)
|
||||||
HOME_DIR=$(eval echo "~$REALUSER")
|
HOME_DIR=$(eval echo "~$REALUSER")
|
||||||
SHARE_DIR="$HOME_DIR/PS2SMB"
|
SHARE_DIR="$HOME_DIR/PS2SMB"
|
||||||
|
@ -21,24 +21,11 @@ else
|
||||||
echo "[✓] Samba is already installed."
|
echo "[✓] Samba is already installed."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create PS2 user if it doesn't exist
|
|
||||||
if ! id "PS2" &>/dev/null; then
|
|
||||||
echo "[*] Creating user 'PS2'..."
|
|
||||||
useradd -M -s /usr/bin/nologin PS2
|
|
||||||
else
|
|
||||||
echo "[✓] User 'PS2' already exists."
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Create the shared directory if it doesn't exist
|
# Create the shared directory if it doesn't exist
|
||||||
echo "[*] Creating share directory at $SHARE_DIR..."
|
echo "[*] Creating share directory at $SHARE_DIR..."
|
||||||
mkdir -p "$SHARE_DIR"
|
mkdir -p "$SHARE_DIR"
|
||||||
chown "$REALUSER:$REALUSER" "$SHARE_DIR"
|
chown "$REALUSER:$REALUSER" "$SHARE_DIR"
|
||||||
|
|
||||||
# Set ACLs so PS2 has full access
|
|
||||||
echo "[*] Setting ACLs for user 'PS2' on $SHARE_DIR..."
|
|
||||||
setfacl -R -m u:PS2:rwx "$SHARE_DIR"
|
|
||||||
setfacl -R -d -m u:PS2:rwx "$SHARE_DIR"
|
|
||||||
|
|
||||||
# Backup original smb.conf
|
# Backup original smb.conf
|
||||||
if [ -f /etc/samba/smb.conf ]; then
|
if [ -f /etc/samba/smb.conf ]; then
|
||||||
echo "[*] Backing up existing /etc/samba/smb.conf to /etc/samba/smb.conf.bak"
|
echo "[*] Backing up existing /etc/samba/smb.conf to /etc/samba/smb.conf.bak"
|
||||||
|
@ -70,11 +57,11 @@ path = $SHARE_DIR
|
||||||
browseable = yes
|
browseable = yes
|
||||||
read only = no
|
read only = no
|
||||||
guest ok = yes
|
guest ok = yes
|
||||||
force user = PS2
|
force user = $REALUSER
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Enable and start Samba
|
# Enable and start Samba
|
||||||
echo "[*] Enabling and starting Samba service..."
|
echo "[*] Enabling and starting Samba service..."
|
||||||
systemctl enable smb --now
|
systemctl enable smb --now
|
||||||
|
|
||||||
echo "[✓] Done. Samba is running and PS2 has access to $SHARE_DIR"
|
echo "[✓] Done. Samba is running and sharing $SHARE_DIR as user $REALUSER"
|
||||||
|
|
Loading…
Add table
Reference in a new issue