New script to rename users

This commit is contained in:
m8in
2026-06-30 07:30:29 +02:00
parent 6591cc60a6
commit 97a5046a10
+19
View File
@@ -0,0 +1,19 @@
#!/bin/bash
source /cis/core/base.module.sh
base.loadModule print
base.set OLD_USER "${1}" "${REGEX[USER]}"
base.set NEW_USER "${2}" "${REGEX[USER]}"
print.highlight "Rename user ${OLD_USER} to ${NEW_USER}: ... " \
&& usermod --login "${NEW_USER}" "${OLD_USER}" \
&& groupmod --new-name "${NEW_USER}" "${OLD_USER}" \
&& usermod --home "/home/${NEW_USER}" --move-home "${NEW_USER}" \
&& mv -f "/home/${OLD_USER}" "/home/${NEW_USER}" \
&& print.done \
&& exit 0
print.fail
exit 1