added path option as cmdline parameter for debugging

This commit is contained in:
Asif Bacchus 2019-01-09 01:55:10 -07:00
parent c0c9b16cf3
commit 2fe6786155
1 changed files with 30 additions and 21 deletions

View File

@ -14,6 +14,15 @@ mag="\e[95m"
err="\e[1;31m"
ok="\e[1;32m"
# allow base copy-path path for debugging, otherwise default to root as base
if [ -n "${1}" ]; then
path="${1%/}"
echo -e "\n${err}BASE PATH:${norm} ${path}"
echo -e "${err}All files will be copied to subdirectories beneath this 'base path' instead"
echo -e "of the correct locations. This should only be done for testing!${norm}\n"
else
unset path
fi
### verify this script is running as root, otherwise exit with notification
if [ $(id -u) -ne 0 ]; then
@ -36,56 +45,56 @@ echo "(please note any errors below)"
## copy clean .bashrc for root user
echo -e "copying ${yellow}.bashrc${norm} to ${yellow}/root${norm}"
echo -e "copying ${yellow}.bashrc${norm} to ${yellow}${path}/root${norm}"
# backup
cp -f /root/.bashrc /root/.bashrc.original
cp -f /root/.bashrc ${path}/root/.bashrc.original
# copy new
cp -f config/root/.bashrc /root/.bashrc
cp -f config/root/.bashrc ${path}/root/.bashrc
## copy profile template file
echo -e "copying ${yellow}profile${norm} to ${yellow}/etc/profile${norm}"
echo -e "copying ${yellow}profile${norm} to ${yellow}${path}/etc/profile${norm}"
# backup
cp -f /etc/profile /etc/profile.original
cp -f /etc/profile ${path}/etc/profile.original
# copy new
cp -f config/etc/profile /etc/profile
cp -f config/etc/profile ${path}/etc/profile
## copy updated bash.bashrc
echo -e "copying ${yellow}bash.bashrc${norm} to ${yellow}/etc/bash.bashrc${norm}"
echo -e "copying ${yellow}bash.bashrc${norm} to ${yellow}${path}/etc/bash.bashrc${norm}"
# backup
cp -f /etc/bash.bashrc /etc/bash.bashrc.original
cp -f /etc/bash.bashrc ${path}/etc/bash.bashrc.original
# copy new
cp -f config/etc/bash.bashrc /etc/bash.bashrc
cp -f config/etc/bash.bashrc ${path}/etc/bash.bashrc
## copy updated skel .bashrc
echo -e "copying ${yellow}.bashrc${norm} to ${yellow}/etc/skel/.bashrc${norm}"
echo -e "copying ${yellow}.bashrc${norm} to ${yellow}${path}/etc/skel/.bashrc${norm}"
# backup
cp -f /etc/skel/.bashrc /etc/skel/.bashrc.original
cp -f /etc/skel/.bashrc ${path}/etc/skel/.bashrc.original
# copy new
cp -f config/etc/skel/.bashrc /etc/skel/.bashrc
cp -f config/etc/skel/.bashrc ${path}/etc/skel/.bashrc
## copy nano settings
echo -e "\ncopying ${yellow}nanorc${norm} to ${yellow}/etc/nanorc${norm}"
echo -e "\ncopying ${yellow}nanorc${norm} to ${yellow}${path}/etc/nanorc${norm}"
# backup
cp -f /etc/nanorc /etc/nanorc.original
cp -f /etc/nanorc ${path}/etc/nanorc.original
# copy new
cp -f config/etc/nanorc /etc/nanorc
cp -f config/etc/nanorc ${path}/etc/nanorc
## copy timesync
echo -e "\ncopying ${yellow}timesyncd.conf${norm} to ${yellow}/etc/systemd/timesyncd.conf${norm}"
echo -e "\ncopying ${yellow}timesyncd.conf${norm} to ${yellow}${path}/etc/systemd/timesyncd.conf${norm}"
# backup
cp -f /etc/systemd/timesyncd.conf /etc/systemd/timesyncd.conf.original
cp -f /etc/systemd/timesyncd.conf ${path}/etc/systemd/timesyncd.conf.original
# copy new
cp -f config/etc/systemd/timesyncd.conf /etc/systemd/timesyncd.conf
cp -f config/etc/systemd/timesyncd.conf ${path}/etc/systemd/timesyncd.conf
## copy sshd configuration
echo -e "\ncopying ${yellow}sshd_config${norm} to ${yellow}/etc/ssh/sshd_config${norm}"
echo -e "\ncopying ${yellow}sshd_config${norm} to ${yellow}${path}/etc/ssh/sshd_config${norm}"
# backup
cp -f /etc/ssh/sshd_config /etc/ssh/sshd_config.original
cp -f /etc/ssh/sshd_config ${path}/etc/ssh/sshd_config.original
# copy new
cp -f config/etc/ssh/sshd_config /etc/ssh/sshd_config
cp -f config/etc/ssh/sshd_config ${path}/etc/ssh/sshd_config
### Exit gracefully