Adds logs and fixes color issue with install-program

This commit is contained in:
Brian Zalewski 2023-11-07 06:25:00 +00:00
parent 27d03ed92a
commit c453b4104f
5 changed files with 24 additions and 6 deletions

View file

@ -53,7 +53,7 @@ through Tor. This script:
# @description Define the Privoxy configuration location based on whether system is macOS or Linux # @description Define the Privoxy configuration location based on whether system is macOS or Linux
if [ -d /Applications ] && [ -d /System ]; then if [ -d /Applications ] && [ -d /System ]; then
# macOS # macOS
PRIVOXY_CONFIG_DIR=/usr/local/etc/privoxy PRIVOXY_CONFIG_DIR="$HOMEBREW_PREFIX/etc/privoxy"
else else
# Linux # Linux
PRIVOXY_CONFIG_DIR=/etc/privoxy PRIVOXY_CONFIG_DIR=/etc/privoxy

View file

@ -22,7 +22,13 @@
# @description Define the Privoxy configuration location based on whether system is macOS or Linux # @description Define the Privoxy configuration location based on whether system is macOS or Linux
if [ -d /Applications ] && [ -d /System ]; then if [ -d /Applications ] && [ -d /System ]; then
# macOS # macOS
if [ -d "/usr/local/etc/privoxy" ]; then
PRIVOXY_CONFIG_DIR=/usr/local/etc/privoxy PRIVOXY_CONFIG_DIR=/usr/local/etc/privoxy
elif [ -d "$HOMEBREW_PREFIX/etc/privoxy" ]; then
PRIVOXY_CONFIG_DIR="$HOMEBREW_PREFIX/etc/privoxy"
else
logg warn 'Unable to detect Privoxy configuration directory'
fi
else else
# Linux # Linux
PRIVOXY_CONFIG_DIR=/etc/privoxy PRIVOXY_CONFIG_DIR=/etc/privoxy

View file

@ -38,13 +38,13 @@ if [[ ! "$(test -d /proc && grep Microsoft /proc/version > /dev/null)" ]]; then
logg info 'Running sudo launchctl stop com.openssh.sshd' logg info 'Running sudo launchctl stop com.openssh.sshd'
sudo launchctl stop com.openssh.sshd sudo launchctl stop com.openssh.sshd
logg info 'Running sudo launchctl start com.openssh.sshd' logg info 'Running sudo launchctl start com.openssh.sshd'
sudo launchctl start com.openssh.sshd sudo launchctl start com.openssh.sshd && logg success 'Successfully ran launchctl start com.openssh.sshd'
else else
# Linux # Linux
logg info 'Enabling the sshd service' logg info 'Enabling the sshd service'
sudo systemctl enable sshd sudo systemctl enable sshd
logg info 'Restarting the sshd service' logg info 'Restarting the sshd service'
sudo systemctl restart sshd sudo systemctl restart sshd && logg success 'Successfully ran sudo systemctl restart sshd'
fi fi
else else
logg warn 'The /etc/ssh folder does not exist' logg warn 'The /etc/ssh folder does not exist'

View file

@ -17,12 +17,15 @@
{{ includeTemplate "universal/profile" }} {{ includeTemplate "universal/profile" }}
{{ includeTemplate "universal/logg" }} {{ includeTemplate "universal/logg" }}
### Notify of script start
logg info 'Configuring fail2ban'
### Restart fail2ban ### Restart fail2ban
function restartFail2Ban() { function restartFail2Ban() {
if [ -d /Applications ] && [ -d /System ]; then if [ -d /Applications ] && [ -d /System ]; then
# macOS # macOS
logg info 'Enabling the fail2ban Homebrew service' logg info 'Enabling the fail2ban Homebrew service'
brew services start fail2ban brew services restart fail2ban
else else
# Linux # Linux
logg info 'Enabling the fail2ban service' logg info 'Enabling the fail2ban service'
@ -33,6 +36,7 @@ function restartFail2Ban() {
} }
### Update the jail.local file if environment is not WSL ### Update the jail.local file if environment is not WSL
logg info 'Checking if script is being run in WSL environment'
if [[ ! "$(test -d /proc && grep Microsoft /proc/version > /dev/null)" ]]; then if [[ ! "$(test -d /proc && grep Microsoft /proc/version > /dev/null)" ]]; then
if [ -d /etc/fail2ban ]; then if [ -d /etc/fail2ban ]; then
logg info 'Copying ~/.ssh/fail2ban/jail.local to /etc/fail2ban/jail.local' logg info 'Copying ~/.ssh/fail2ban/jail.local to /etc/fail2ban/jail.local'
@ -42,6 +46,10 @@ if [[ ! "$(test -d /proc && grep Microsoft /proc/version > /dev/null)" ]]; then
logg info 'Copying ~/.ssh/fail2ban/jail.local to /usr/local/etc/fail2ban/jail.local' logg info 'Copying ~/.ssh/fail2ban/jail.local to /usr/local/etc/fail2ban/jail.local'
sudo cp -f "$HOME/.ssh/fail2ban/jail.local" /usr/local/etc/fail2ban/jail.local sudo cp -f "$HOME/.ssh/fail2ban/jail.local" /usr/local/etc/fail2ban/jail.local
restartFail2Ban restartFail2Ban
elif [ -d "$HOMEBREW_PREFIX/etc/fail2ban" ]; then
logg info "Copying ~/.ssh/fail2ban/jail.local to $HOMEBREW_PREFIX/etc/fail2ban/jail.local"
sudo cp -f "$HOME/.ssh/fail2ban/jail.local" "$HOMEBREW_PREFIX/etc/fail2ban/jail.local"
restartFail2Ban
else else
logg warn 'Both the /etc/fail2ban (Linux) and the /usr/local/etc/fail2ban (macOS) folder do not exist' logg warn 'Both the /etc/fail2ban (Linux) and the /usr/local/etc/fail2ban (macOS) folder do not exist'
fi fi

View file

@ -1913,7 +1913,11 @@ async function installSoftware(pkgsToInstall) {
} }
installOrdersPre.length && log('info', 'Pre-Install', `Running package-specific pre-installation steps`) installOrdersPre.length && log('info', 'Pre-Install', `Running package-specific pre-installation steps`)
for (const script of installOrdersPre) { for (const script of installOrdersPre) {
await $`source "${process.env.HOME}/.bashrc" && ${script.replace(/\n/g, "\\\n")}` console.log(`. "${process.env.HOME}/.bashrc" && ${script.replace(/\n/g, "\\\n")}`)
console.log(script.toString())
console.log(script)
console.log(script.replace(/\n/g, "\\\n").replace(/^$'/, ""))
await $`. "${process.env.HOME}/.config/shell/profile.sh" && ${script.replace(/\n/g, "\\\n").replace(/^\$'/, "").replace(/'$/, "")}`
} }
installOrdersGroups.length && log('info', 'Users / Groups', `Adding groups / users`) installOrdersGroups.length && log('info', 'Users / Groups', `Adding groups / users`)
for (const group of installOrdersGroups) { for (const group of installOrdersGroups) {