Last active
April 7, 2026 15:01
-
-
Save 0xAungkon/48d9da955ddfebc6dadc928c01a8ef46 to your computer and use it in GitHub Desktop.
oneclick samba setup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| set -e | |
| if ! command -v apt >/dev/null 2>&1; then | |
| echo "Debian/Ubuntu only." | |
| exit 1 | |
| fi | |
| USER_NAME="${SUDO_USER:-$USER}" | |
| sudo apt update | |
| sudo apt install -y samba | |
| sudo cp -n /etc/samba/smb.conf /etc/samba/smb.conf.bak | |
| if ! grep -q "^\[homes\]" /etc/samba/smb.conf; then | |
| sudo tee -a /etc/samba/smb.conf >/dev/null <<EOF | |
| [homes] | |
| comment = Home Directories | |
| browseable = yes | |
| writable = yes | |
| create mask = 0700 | |
| directory mask = 0700 | |
| valid users = %S | |
| EOF | |
| fi | |
| echo "Enter Samba password for user: $USER_NAME" | |
| sudo smbpasswd -a "$USER_NAME" < /dev/tty | |
| sudo smbpasswd -e "$USER_NAME" | |
| sudo systemctl enable smbd nmbd | |
| sudo systemctl restart smbd nmbd | |
| echo "Samba configured: //$HOSTNAME/$USER_NAME" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment