From 1fd6b46996bd73b408d0ebb595e995604342b15c Mon Sep 17 00:00:00 2001 From: JensDiemer Date: Tue, 27 Oct 2020 09:15:43 +0100 Subject: [PATCH] add root server helper shell scripts --- scripts/apt-distupgrade.sh | 14 ++++++++++++++ scripts/setup_user.sh | 21 +++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100755 scripts/apt-distupgrade.sh create mode 100644 scripts/setup_user.sh diff --git a/scripts/apt-distupgrade.sh b/scripts/apt-distupgrade.sh new file mode 100755 index 0000000..7558646 --- /dev/null +++ b/scripts/apt-distupgrade.sh @@ -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 +) diff --git a/scripts/setup_user.sh b/scripts/setup_user.sh new file mode 100644 index 0000000..d95c466 --- /dev/null +++ b/scripts/setup_user.sh @@ -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} \ No newline at end of file