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
if [ -d /Applications ] && [ -d /System ]; then
# macOS
PRIVOXY_CONFIG_DIR=/usr/local/etc/privoxy
PRIVOXY_CONFIG_DIR="$HOMEBREW_PREFIX/etc/privoxy"
else
# Linux
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
if [ -d /Applications ] && [ -d /System ]; then
# macOS
PRIVOXY_CONFIG_DIR=/usr/local/etc/privoxy
if [ -d "/usr/local/etc/privoxy" ]; then
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
# Linux
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'
sudo launchctl stop 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
# Linux
logg info 'Enabling the sshd service'
sudo systemctl enable sshd
logg info 'Restarting the sshd service'
sudo systemctl restart sshd
sudo systemctl restart sshd && logg success 'Successfully ran sudo systemctl restart sshd'
fi
else
logg warn 'The /etc/ssh folder does not exist'

View file

@ -17,12 +17,15 @@
{{ includeTemplate "universal/profile" }}
{{ includeTemplate "universal/logg" }}
### Notify of script start
logg info 'Configuring fail2ban'
### Restart fail2ban
function restartFail2Ban() {
if [ -d /Applications ] && [ -d /System ]; then
# macOS
logg info 'Enabling the fail2ban Homebrew service'
brew services start fail2ban
brew services restart fail2ban
else
# Linux
logg info 'Enabling the fail2ban service'
@ -33,6 +36,7 @@ function restartFail2Ban() {
}
### 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 [ -d /etc/fail2ban ]; then
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'
sudo cp -f "$HOME/.ssh/fail2ban/jail.local" /usr/local/etc/fail2ban/jail.local
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
logg warn 'Both the /etc/fail2ban (Linux) and the /usr/local/etc/fail2ban (macOS) folder do not exist'
fi

View file

@ -1913,7 +1913,11 @@ async function installSoftware(pkgsToInstall) {
}
installOrdersPre.length && log('info', 'Pre-Install', `Running package-specific pre-installation steps`)
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`)
for (const group of installOrdersGroups) {