2019-01-01 23:27:17 -07:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#######
|
|
|
|
### Copy customization files to their proper locations after backing up
|
|
|
|
### original files
|
|
|
|
#######
|
|
|
|
|
2019-01-09 00:55:38 -07:00
|
|
|
|
|
|
|
# colour definitions
|
|
|
|
norm="\e[0m"
|
|
|
|
yellow="\e[93m"
|
|
|
|
cyan="\e[96m"
|
|
|
|
mag="\e[95m"
|
|
|
|
err="\e[1;31m"
|
|
|
|
ok="\e[1;32m"
|
|
|
|
|
2019-01-09 01:55:10 -07:00
|
|
|
# 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
|
2019-01-09 00:59:51 -07:00
|
|
|
|
2019-01-09 01:07:05 -07:00
|
|
|
### verify this script is running as root, otherwise exit with notification
|
2019-01-01 23:27:17 -07:00
|
|
|
if [ $(id -u) -ne 0 ]; then
|
2019-01-09 00:59:51 -07:00
|
|
|
echo -e "\n${err}This script MUST be run as ROOT. Exiting${norm}"
|
2019-01-01 23:27:17 -07:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2019-01-09 00:59:51 -07:00
|
|
|
|
2019-01-09 01:07:05 -07:00
|
|
|
### let user know what's happening
|
2019-01-09 00:59:51 -07:00
|
|
|
echo -e "\n${norm}This script will copy TEMPLATE files to various locations in order to customize"
|
2019-01-09 00:51:23 -07:00
|
|
|
echo "your system. Backups will be created in-place with the extension '.original'"
|
2019-01-09 00:59:51 -07:00
|
|
|
echo -e "\n${yellow}Please note: It's still up to you to customize the template files with settings"
|
2019-01-09 00:51:23 -07:00
|
|
|
echo "appropriate to your environment!"
|
2019-01-09 00:59:51 -07:00
|
|
|
echo -e "\n${cyan}Details about template files are in the readme.md files within each directory"
|
|
|
|
echo -e "in this archive.${norm}\n"
|
2019-01-01 23:27:17 -07:00
|
|
|
|
2019-01-09 01:07:05 -07:00
|
|
|
### copy files to proper locations
|
2019-01-09 01:00:16 -07:00
|
|
|
echo -e "${mag}---------------------${norm}"
|
2019-01-09 01:02:21 -07:00
|
|
|
echo "(please note any errors below)"
|
2019-01-01 23:27:17 -07:00
|
|
|
|
2019-01-09 01:08:42 -07:00
|
|
|
|
2019-01-09 01:07:39 -07:00
|
|
|
## copy clean .bashrc for root user
|
2019-01-09 01:55:10 -07:00
|
|
|
echo -e "copying ${yellow}.bashrc${norm} to ${yellow}${path}/root${norm}"
|
2019-01-01 23:27:17 -07:00
|
|
|
# backup
|
2019-01-09 01:55:10 -07:00
|
|
|
cp -f /root/.bashrc ${path}/root/.bashrc.original
|
2019-01-01 23:27:17 -07:00
|
|
|
# copy new
|
2019-01-09 01:55:10 -07:00
|
|
|
cp -f config/root/.bashrc ${path}/root/.bashrc
|
2019-01-01 23:27:17 -07:00
|
|
|
|
2019-01-09 01:08:42 -07:00
|
|
|
## copy profile template file
|
2019-01-09 01:55:10 -07:00
|
|
|
echo -e "copying ${yellow}profile${norm} to ${yellow}${path}/etc/profile${norm}"
|
2019-01-01 23:27:17 -07:00
|
|
|
# backup
|
2019-01-09 01:55:10 -07:00
|
|
|
cp -f /etc/profile ${path}/etc/profile.original
|
2019-01-01 23:27:17 -07:00
|
|
|
# copy new
|
2019-01-09 01:55:10 -07:00
|
|
|
cp -f config/etc/profile ${path}/etc/profile
|
2019-01-09 01:08:42 -07:00
|
|
|
|
|
|
|
## copy updated bash.bashrc
|
2019-01-09 01:55:10 -07:00
|
|
|
echo -e "copying ${yellow}bash.bashrc${norm} to ${yellow}${path}/etc/bash.bashrc${norm}"
|
2019-01-09 01:08:42 -07:00
|
|
|
# backup
|
2019-01-09 01:55:10 -07:00
|
|
|
cp -f /etc/bash.bashrc ${path}/etc/bash.bashrc.original
|
2019-01-09 01:08:42 -07:00
|
|
|
# copy new
|
2019-01-09 01:55:10 -07:00
|
|
|
cp -f config/etc/bash.bashrc ${path}/etc/bash.bashrc
|
2019-01-09 01:08:42 -07:00
|
|
|
|
|
|
|
## copy updated skel .bashrc
|
2019-01-09 01:55:10 -07:00
|
|
|
echo -e "copying ${yellow}.bashrc${norm} to ${yellow}${path}/etc/skel/.bashrc${norm}"
|
2019-01-09 01:08:42 -07:00
|
|
|
# backup
|
2019-01-09 01:55:10 -07:00
|
|
|
cp -f /etc/skel/.bashrc ${path}/etc/skel/.bashrc.original
|
2019-01-09 01:08:42 -07:00
|
|
|
# copy new
|
2019-01-09 01:55:10 -07:00
|
|
|
cp -f config/etc/skel/.bashrc ${path}/etc/skel/.bashrc
|
2019-01-09 01:08:42 -07:00
|
|
|
|
2019-01-01 23:27:17 -07:00
|
|
|
|
|
|
|
## copy nano settings
|
2019-01-09 01:55:10 -07:00
|
|
|
echo -e "\ncopying ${yellow}nanorc${norm} to ${yellow}${path}/etc/nanorc${norm}"
|
2019-01-01 23:27:17 -07:00
|
|
|
# backup
|
2019-01-09 01:55:10 -07:00
|
|
|
cp -f /etc/nanorc ${path}/etc/nanorc.original
|
2019-01-01 23:27:17 -07:00
|
|
|
# copy new
|
2019-01-09 01:55:10 -07:00
|
|
|
cp -f config/etc/nanorc ${path}/etc/nanorc
|
2019-01-09 01:10:08 -07:00
|
|
|
|
2019-01-01 23:27:17 -07:00
|
|
|
|
|
|
|
## copy timesync
|
2019-01-09 01:55:10 -07:00
|
|
|
echo -e "\ncopying ${yellow}timesyncd.conf${norm} to ${yellow}${path}/etc/systemd/timesyncd.conf${norm}"
|
2019-01-01 23:27:17 -07:00
|
|
|
# backup
|
2019-01-09 01:55:10 -07:00
|
|
|
cp -f /etc/systemd/timesyncd.conf ${path}/etc/systemd/timesyncd.conf.original
|
2019-01-01 23:27:17 -07:00
|
|
|
# copy new
|
2019-01-09 01:55:10 -07:00
|
|
|
cp -f config/etc/systemd/timesyncd.conf ${path}/etc/systemd/timesyncd.conf
|
2019-01-09 01:11:19 -07:00
|
|
|
|
2019-01-01 23:27:17 -07:00
|
|
|
|
|
|
|
## copy sshd configuration
|
2019-01-09 01:55:10 -07:00
|
|
|
echo -e "\ncopying ${yellow}sshd_config${norm} to ${yellow}${path}/etc/ssh/sshd_config${norm}"
|
2019-01-01 23:27:17 -07:00
|
|
|
# backup
|
2019-01-09 01:55:10 -07:00
|
|
|
cp -f /etc/ssh/sshd_config ${path}/etc/ssh/sshd_config.original
|
2019-01-01 23:27:17 -07:00
|
|
|
# copy new
|
2019-01-09 01:55:10 -07:00
|
|
|
cp -f config/etc/ssh/sshd_config ${path}/etc/ssh/sshd_config
|
2019-01-09 01:12:02 -07:00
|
|
|
|
2019-01-09 00:59:51 -07:00
|
|
|
|
2019-01-01 23:27:17 -07:00
|
|
|
### Exit gracefully
|
2019-01-09 01:12:39 -07:00
|
|
|
echo -e "${mag}---------------------${norm}"
|
2019-01-09 00:59:51 -07:00
|
|
|
echo -e "\n${ok}All done!${norm}\n"
|
2019-01-01 23:27:17 -07:00
|
|
|
|
|
|
|
exit 0
|