From 7db81d0ee045aeb9a2d942af2f346dad2f2d26ab Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Wed, 21 Apr 2021 10:25:12 +0200 Subject: [PATCH] Improved write_bashrc.py --- users/vsrv/scripts/server_installation.sh | 2 +- users/vsrv/scripts/write_bashrc.py | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/users/vsrv/scripts/server_installation.sh b/users/vsrv/scripts/server_installation.sh index 6bc2732..4469d4f 100644 --- a/users/vsrv/scripts/server_installation.sh +++ b/users/vsrv/scripts/server_installation.sh @@ -17,7 +17,7 @@ install_git install_lsd install_ncdu echo 'echo ""' | sudo tee -a /etc/bash.bashrc > /dev/null -sudo python3.9 write_bashrc.py +sudo python3.9 write_bashrc.py /home/ /root/ install_neofetch install_trash_cli diff --git a/users/vsrv/scripts/write_bashrc.py b/users/vsrv/scripts/write_bashrc.py index 406ff8a..140c495 100644 --- a/users/vsrv/scripts/write_bashrc.py +++ b/users/vsrv/scripts/write_bashrc.py @@ -10,6 +10,13 @@ Script to comment all alias ls="ls *" to allow global bashrc alias ls="lsd" :copyright: (c) 2021 sh-edraft.de :license: MIT, see LICENSE for more details. +At first check for root +Then load all .bashrc files from /home// +Each folder in /home/ must contain a .bashrc file, if not it won't be created + +Usage: sudo python write_bashrc.py +Example: sudo python write_bashrc.py /home/ /root/ + """ __title__ = 'sh_write_bashrc' @@ -18,9 +25,7 @@ __license__ = 'MIT' __copyright__ = 'Copyright (c) 2021 sh-edraft.de' __version__ = '2021.4' -# At first check for root -# Then load all .bashrc files from /home// -# Each folder in /home/ must contain a .bashrc file, if not it won't be created + import os import sys @@ -83,8 +88,12 @@ def _edit_script(file: str): def main(): + if len(sys.argv) < 3: + print('Usage: sudo pyhton write_bashrc.py ') + exit() + _check_dependencies() - files = _load_all_scripts('/home/', '/root/') + files = _load_all_scripts(sys.argv[1], sys.argv[2]) for file in files: _edit_script(file)