I'm trying to build a baseline tools installer for Kali Linux, basically, a script that installs all the tools I usually have to install manually, but also creates a new user and switches to it.
My script so far looks like this:
# --------------
# Imports
# --------------
import os
import getpass
# --------------
# Get Username
user = getpass.getuser()
# -
# Colors
colorGreen = "\033[1; 32; 40m end="""
# -
# --------------
# Functions
# --------------
# Update & Upgrade
def upgrade():
os.system('sudo apt update && sudo apt upgrade')
# -
# Add new User
def addUser():
print("### Creating a Low Priv User ###")
user = input("Choose a username: ")
os.system('sudo adduser ' + user)
print("### Adding new user to Sudo ###")
os.system("sudo usermod -aG sudo " + user)
os.system("sudo chsh -s /bin/bash " + user)
print("### Done ###")
print("### Switching to new user... ###")
os.system("su " + user)
print("### Done! Welcome {}".format(user))
# --------------
# Function Calls
# --------------
upgrade()
addUser()
# -
As soon as I reach the end, which is os.system("su " + user)
, the script naturally stops. su %username% is the command to switch to the newly created user.
Ideally, I want that the script keeps running after that, so I am able to install the tools within the newly created user.
Is there a way to achieve this? Or is there another way to do this? I know I could use something like
git clone NewTool/home/{user}/opt/
and go from there, but that seems inconvenient.
It would be great if someone can point me in the right direction!
Cheers