add root server helper shell scripts

pull/20/head
JensDiemer 2020-10-27 09:15:43 +01:00
rodzic edf7ea2919
commit 1fd6b46996
2 zmienionych plików z 35 dodań i 0 usunięć

Wyświetl plik

@ -0,0 +1,14 @@
#!/bin/bash
(
set -x
sudo apt update
{ echo "---------------------------------------------------"; } 2>/dev/null
sudo apt -y full-upgrade
{ echo "---------------------------------------------------"; } 2>/dev/null
sudo apt -y autoremove
{ echo "---------------------------------------------------"; } 2>/dev/null
# Delete old entries:
sudo journalctl --vacuum-size=1G
sudo journalctl --vacuum-time=1years
)

Wyświetl plik

@ -0,0 +1,21 @@
#!/usr/bin/env bash
if [ "$(whoami)" != "root" ]; then
echo "Please start with 'sudo' !"
(
set -x
id
exit 1
)
fi
set -ex
export USERNAME=${1}
adduser --disabled-password --gecos "" --home=/home/${USERNAME} ${USERNAME}
mkdir -p /home/${USERNAME}/.ssh
cp /root/.ssh/authorized_keys /home/${USERNAME}/.ssh/
chown -Rfc ${USERNAME}.${USERNAME} /home/${USERNAME}/
echo "${USERNAME} ALL=(ALL) NOPASSWD:ALL">/etc/sudoers.d/${USERNAME}