crlf fix
This commit is contained in:
parent
7a3ed0893d
commit
2aa19dc62a
20
README.md
20
README.md
@ -1,10 +1,10 @@
|
|||||||
Run:
|
Run:
|
||||||
|
|
||||||
curl -H "Authorization: token READ_REPOSITORY_ACCESS_TOKEN" -O https://git.rozenlab.com/api/v1/repos/leo/server-init/raw/init.sh?ref=master && sudo bash init.sh && rm init.sh
|
curl -H "Authorization: token READ_REPOSITORY_ACCESS_TOKEN" -O https://git.rozenlab.com/api/v1/repos/leo/server-init/raw/init.sh?ref=master && sudo bash init.sh && rm init.sh
|
||||||
|
|
||||||
curl -H "Authorization: token READ_REPOSITORY_ACCESS_TOKEN" -O https://git.rozenlab.com/api/v1/repos/leo/server-init/raw/samba.sh?ref=master && sudo bash samba.sh SAMBA_USER SAMBA_PASSWORD && rm samba.sh
|
curl -H "Authorization: token READ_REPOSITORY_ACCESS_TOKEN" -O https://git.rozenlab.com/api/v1/repos/leo/server-init/raw/samba.sh?ref=master && sudo bash samba.sh SAMBA_USER SAMBA_PASSWORD && rm samba.sh
|
||||||
|
|
||||||
|
|
||||||
**git**
|
**git**
|
||||||
git remote add server-init https://git.rozenlab.com/Leo/server-init.git
|
git remote add server-init https://git.rozenlab.com/Leo/server-init.git
|
||||||
git add -A && git commit -m "changes" && git push server-init master
|
git add -A && git commit -m "changes" && git push server-init master
|
||||||
|
@ -1,44 +1,44 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
USERNAME=usradmin
|
USERNAME=usradmin
|
||||||
SSH_PORT=2525
|
SSH_PORT=2525
|
||||||
|
|
||||||
if [ "$(id -u)" != "0" ]; then
|
if [ "$(id -u)" != "0" ]; then
|
||||||
echo -e "\033[31mThis script requires superuser rights.\033[0m"
|
echo -e "\033[31mThis script requires superuser rights.\033[0m"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
trap 'echo -e "\033[31mSomething went wrong\033[0m"; exit 1' ERR
|
trap 'echo -e "\033[31mSomething went wrong\033[0m"; exit 1' ERR
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
export DEBIAN_FRONTEND=noninteractive
|
export DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
apt update -y
|
apt update -y
|
||||||
apt upgrade -y
|
apt upgrade -y
|
||||||
apt install -y mc vim zip pwgen sshpass
|
apt install -y mc vim zip pwgen
|
||||||
|
|
||||||
timedatectl set-timezone Asia/Yekaterinburg
|
timedatectl set-timezone Asia/Yekaterinburg
|
||||||
echo "Timezone changed:"
|
echo "Timezone changed:"
|
||||||
timedatectl
|
timedatectl
|
||||||
|
|
||||||
if id "$USERNAME" &>/dev/null; then
|
if id "$USERNAME" &>/dev/null; then
|
||||||
echo "User $USERNAME already exists"
|
echo "User $USERNAME already exists"
|
||||||
else
|
else
|
||||||
useradd -m -s /bin/bash "$USERNAME"
|
useradd -m -s /bin/bash "$USERNAME"
|
||||||
usermod -aG sudo "$USERNAME"
|
usermod -aG sudo "$USERNAME"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
chown "$USERNAME":"$USERNAME" /data
|
chown "$USERNAME":"$USERNAME" /data
|
||||||
chmod 770 /data
|
chmod 770 /data
|
||||||
|
|
||||||
mkdir -p /backups
|
mkdir -p /backups
|
||||||
chown "$USERNAME":"$USERNAME" /backups
|
chown "$USERNAME":"$USERNAME" /backups
|
||||||
chmod 770 /backups
|
chmod 770 /backups
|
||||||
|
|
||||||
# SSH config:
|
# SSH config:
|
||||||
cd /data/utils
|
cd /data/utils
|
||||||
bash ssh-port.sh $SSH_PORT
|
bash ssh-port.sh $SSH_PORT
|
||||||
#bash ssh-pw.sh n
|
#bash ssh-pw.sh n
|
||||||
|
|
||||||
trap - ERR
|
trap - ERR
|
||||||
echo "Init complete"
|
echo "Init complete"
|
158
samba.sh
158
samba.sh
@ -1,80 +1,80 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
if [ "$(id -u)" != "0" ]; then
|
if [ "$(id -u)" != "0" ]; then
|
||||||
echo -e "\033[31mThis script requires superuser rights.\033[0m"
|
echo -e "\033[31mThis script requires superuser rights.\033[0m"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$1" ] || [ -z "$2" ]; then
|
if [ -z "$1" ] || [ -z "$2" ]; then
|
||||||
echo "Please provide both the username and password as arguments."
|
echo "Please provide both the username and password as arguments."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
trap 'echo -e "\033[31mSomething went wrong\033[0m"; exit 1' EXIT
|
trap 'echo -e "\033[31mSomething went wrong\033[0m"; exit 1' EXIT
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
export DEBIAN_FRONTEND=noninteractive
|
export DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
SMB_CONF="/etc/samba/smb.conf"
|
SMB_CONF="/etc/samba/smb.conf"
|
||||||
USERNAME="$1"
|
USERNAME="$1"
|
||||||
PASSWORD="$2"
|
PASSWORD="$2"
|
||||||
|
|
||||||
apt update -y
|
apt update -y
|
||||||
apt install -y samba
|
apt install -y samba
|
||||||
systemctl enable smbd
|
systemctl enable smbd
|
||||||
systemctl start smbd
|
systemctl start smbd
|
||||||
|
|
||||||
mkdir -p /data
|
mkdir -p /data
|
||||||
(echo "$PASSWORD"; echo "$PASSWORD") | smbpasswd -a -s "$USERNAME"
|
(echo "$PASSWORD"; echo "$PASSWORD") | smbpasswd -a -s "$USERNAME"
|
||||||
|
|
||||||
smbpasswd -e "$USERNAME"
|
smbpasswd -e "$USERNAME"
|
||||||
chown "$USERNAME":"$USERNAME" /data/
|
chown "$USERNAME":"$USERNAME" /data/
|
||||||
chmod 770 /data/
|
chmod 770 /data/
|
||||||
|
|
||||||
# Backup existing configuration file
|
# Backup existing configuration file
|
||||||
cp "$SMB_CONF" "${SMB_CONF}.bak"
|
cp "$SMB_CONF" "${SMB_CONF}.bak"
|
||||||
|
|
||||||
# New section
|
# New section
|
||||||
NEW_SECTION=$(cat << EOM
|
NEW_SECTION=$(cat << EOM
|
||||||
|
|
||||||
# data folder access
|
# data folder access
|
||||||
[data]
|
[data]
|
||||||
path = /data
|
path = /data
|
||||||
read only = no
|
read only = no
|
||||||
browseable = yes
|
browseable = yes
|
||||||
create mask = 0666
|
create mask = 0666
|
||||||
force create mode = 0666
|
force create mode = 0666
|
||||||
directory mask = 0777
|
directory mask = 0777
|
||||||
force directory mode = 0777
|
force directory mode = 0777
|
||||||
valid users = $USERNAME
|
valid users = $USERNAME
|
||||||
|
|
||||||
# backups folder access
|
# backups folder access
|
||||||
[backups]
|
[backups]
|
||||||
path = /backups
|
path = /backups
|
||||||
read only = no
|
read only = no
|
||||||
browseable = yes
|
browseable = yes
|
||||||
create mask = 0666
|
create mask = 0666
|
||||||
force create mode = 0666
|
force create mode = 0666
|
||||||
directory mask = 0777
|
directory mask = 0777
|
||||||
force directory mode = 0777
|
force directory mode = 0777
|
||||||
valid users = $USERNAME
|
valid users = $USERNAME
|
||||||
|
|
||||||
EOM
|
EOM
|
||||||
)
|
)
|
||||||
|
|
||||||
# Adding a new section to the end of the configuration file
|
# Adding a new section to the end of the configuration file
|
||||||
echo "$NEW_SECTION" | tee -a "$SMB_CONF" > /dev/null
|
echo "$NEW_SECTION" | tee -a "$SMB_CONF" > /dev/null
|
||||||
|
|
||||||
if grep -q "^obey pam restrictions = yes" "$SMB_CONF"; then
|
if grep -q "^obey pam restrictions = yes" "$SMB_CONF"; then
|
||||||
sed -i 's/^obey pam restrictions = yes/obey pam restrictions = no/' "$SMB_CONF"
|
sed -i 's/^obey pam restrictions = yes/obey pam restrictions = no/' "$SMB_CONF"
|
||||||
echo "Param 'obey pam restrictions' changed to 'no'"
|
echo "Param 'obey pam restrictions' changed to 'no'"
|
||||||
else
|
else
|
||||||
echo "Param 'obey pam restrictions = yes' not found."
|
echo "Param 'obey pam restrictions = yes' not found."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Samba configuration updated and saved to $SMB_CONF."
|
echo "Samba configuration updated and saved to $SMB_CONF."
|
||||||
|
|
||||||
systemctl restart smbd nmbd
|
systemctl restart smbd nmbd
|
||||||
|
|
||||||
trap - EXIT
|
trap - EXIT
|
||||||
echo "Samba configured complete."
|
echo "Samba configured complete."
|
Loading…
Reference in New Issue
Block a user