Update install script and utils

Signed-off-by: Severin Kaderli <severin@kaderli.dev>
This commit is contained in:
Severin Kaderli 2019-09-17 18:50:16 +02:00
parent 7e6a5dd4da
commit b4361d455e
Signed by: severinkaderli
GPG key ID: F419F8835B72F0C4
2 changed files with 21 additions and 23 deletions

22
install
View file

@ -266,7 +266,7 @@ print_section "Creating directories"
for dir in "${DIRECTORIES[@]}" for dir in "${DIRECTORIES[@]}"
do do
print_log "Creating directory ${YELLOW}${HOME}/${dir}${RESET}" print_log "Creating directory ${YELLOW}${HOME}/${dir}${DEFAULT}"
mkdir -p "${HOME}/${dir}" mkdir -p "${HOME}/${dir}"
done done
@ -286,13 +286,13 @@ fi
print_section "Creating symlinks" print_section "Creating symlinks"
for file in "${LINKED_FILES_HOME[@]}"; for file in "${LINKED_FILES_HOME[@]}";
do do
print_log "Linking ${YELLOW}${HOME}/${file}${RESET} to ${YELLOW}${SYSTEM_DIR}/${file}${RESET}" print_log "Linking ${YELLOW}${HOME}/${file}${DEFAULT} to ${YELLOW}${SYSTEM_DIR}/${file}${DEFAULT}"
rm -rf "${HOME:?}/${file}" rm -rf "${HOME:?}/${file}"
ln -fs "${SYSTEM_DIR}/${file}" "${HOME}/${file}" ln -fs "${SYSTEM_DIR}/${file}" "${HOME}/${file}"
done done
for file in "${!LINKED_FILES[@]}"; do for file in "${!LINKED_FILES[@]}"; do
print_log "Linking ${YELLOW}${file}${RESET} to ${YELLOW}${LINKED_FILES[${file}]}${RESET}" print_log "Linking ${YELLOW}${file}${DEFAULT} to ${YELLOW}${LINKED_FILES[${file}]}${DEFAULT}"
rm -rf "${file}" rm -rf "${file}"
ln -fs "${LINKED_FILES[${file}]}" "${file}" ln -fs "${LINKED_FILES[${file}]}" "${file}"
done done
@ -303,9 +303,9 @@ done
############################################################################### ###############################################################################
print_section "Giving permissions" print_section "Giving permissions"
for permission in "${!PERMISSIONS[@]}"; do for permission in "${!PERMISSIONS[@]}"; do
print_log "Changing owner of ${YELLOW}${permission}${RESET} to ${YELLOW}${USER}${RESET}" print_log "Changing owner of ${YELLOW}${permission}${DEFAULT} to ${YELLOW}${USER}${DEFAULT}"
sudo chown -R "${USER}" "${permission}" sudo chown -R "${USER}" "${permission}"
print_log "Changing permission of ${YELLOW}${permission}${RESET} to ${YELLOW}${PERMISSIONS[${permission}]}${RESET}" print_log "Changing permission of ${YELLOW}${permission}${DEFAULT} to ${YELLOW}${PERMISSIONS[${permission}]}${DEFAULT}"
sudo chmod -R "${PERMISSIONS[${permission}]}" "${permission}" sudo chmod -R "${PERMISSIONS[${permission}]}" "${permission}"
done done
@ -316,7 +316,7 @@ done
print_section "Adding user to groups" print_section "Adding user to groups"
for group in "${ADD_GROUPS[@]}" for group in "${ADD_GROUPS[@]}"
do do
print_log "Adding user ${YELLOW}${USER}${RESET} to group ${YELLOW}${group}${RESET}" print_log "Adding user ${YELLOW}${USER}${DEFAULT} to group ${YELLOW}${group}${DEFAULT}"
sudo gpasswd -a "${USER}" "${group}" > /dev/null 2>&1 sudo gpasswd -a "${USER}" "${group}" > /dev/null 2>&1
done done
@ -327,7 +327,7 @@ done
print_section "Copying systemd services" print_section "Copying systemd services"
for file in "${SYSTEM_DIR}/etc/systemd/system/"* for file in "${SYSTEM_DIR}/etc/systemd/system/"*
do do
print_log "Copying ${YELLOW}$(basename "${file}")${RESET} to ${YELLOW}/etc/systemd/system${RESET}" print_log "Copying ${YELLOW}$(basename "${file}")${DEFAULT} to ${YELLOW}/etc/systemd/system${DEFAULT}"
sudo install -m 644 "${file}" "/etc/systemd/system" sudo install -m 644 "${file}" "/etc/systemd/system"
done done
@ -338,13 +338,13 @@ done
print_section "Enabling systemd services" print_section "Enabling systemd services"
for service in "${SYSTEMD_SERVICES[@]}" for service in "${SYSTEMD_SERVICES[@]}"
do do
print_log "Enabling service ${YELLOW}${service}${RESET}" print_log "Enabling service ${YELLOW}${service}${DEFAULT}"
sudo systemctl enable "${service}" sudo systemctl enable "${service}"
done done
for service in "${SYSTEMD_USER_SERVICES[@]}" for service in "${SYSTEMD_USER_SERVICES[@]}"
do do
print_log "Enabling service ${YELLOW}${service}${RESET}" print_log "Enabling service ${YELLOW}${service}${DEFAULT}"
systemctl --user enable "${service}" systemctl --user enable "${service}"
done done
@ -355,7 +355,7 @@ done
print_section "Copying custom udev rules" print_section "Copying custom udev rules"
for file in "${SYSTEM_DIR}/etc/udev/rules.d/"*.rules for file in "${SYSTEM_DIR}/etc/udev/rules.d/"*.rules
do do
print_log "Copying ${YELLOW}$(basename "${file}")${RESET} to ${YELLOW}/etc/udev/rules.d/${RESET}" print_log "Copying ${YELLOW}$(basename "${file}")${DEFAULT} to ${YELLOW}/etc/udev/rules.d/${DEFAULT}"
sudo cp "${file}" "/etc/udev/rules.d/" sudo cp "${file}" "/etc/udev/rules.d/"
done done
sudo udevadm control --reload-rules sudo udevadm control --reload-rules
@ -366,7 +366,7 @@ sudo udevadm control --reload-rules
############################################################################### ###############################################################################
print_section "Copying root files" print_section "Copying root files"
for file in "${!COPY_ROOT_FILES[@]}"; do for file in "${!COPY_ROOT_FILES[@]}"; do
print_log "Copying ${YELLOW}${file}${RESET}" print_log "Copying ${YELLOW}${file}${DEFAULT}"
sudo install -Dm "${COPY_ROOT_FILES[${file}]}" "${SYSTEM_DIR}${file}" "${file}" sudo install -Dm "${COPY_ROOT_FILES[${file}]}" "${SYSTEM_DIR}${file}" "${file}"
done done

View file

@ -22,13 +22,13 @@ PACKAGES_DIR="${DIR}/packages"
####################################### #######################################
# Bash color code variables # Bash color code variables
####################################### #######################################
RESET='\033[0m' RESET="$(tput sgr0)"
GREEN='\033[32m' GREEN="$(tput setaf 2)"
RED='\033[31m' RED="$(tput setaf 1)"
BLUE='\033[34m' BLUE="$(tput setaf 4)"
YELLOW='\033[33m' DEFAULT="$(tput op)"
YELLOW="$(tput setaf 3)"
BOLD="$(tput bold)" BOLD="$(tput bold)"
NORMAL="$(tput sgr0)"
####################################### #######################################
# Helper functions # Helper functions
@ -44,23 +44,21 @@ function print_time_log() {
# USAGE: print_notify TITLE MESSAGE # USAGE: print_notify TITLE MESSAGE
function print_notify() { function print_notify() {
notify-send "${1}" "${2}" notify-send "${1}" "${2}"
echo -e "${YELLOW}[$(date "+%T")] ${1} ${2}${RESET}" echo -e "${YELLOW}[$(date "+%T")] ${1} ${2}${DEFAULT}"
} }
# Prints a section title. # Prints a section title.
# USAGE: print_section TITLE # USAGE: print_section TITLE
function print_section() { function print_section() {
echo -e "${YELLOW}${BOLD}┌──────────────────────────────────────────────────────────────────────────────┐" echo -e "${BOLD}${BLUE}::${DEFAULT} ${1}${RESET}"
echo -e "│ $(printf "%-77s" "${1}")│"
echo -e "└──────────────────────────────────────────────────────────────────────────────┘${RESET}"
} }
function print_log() { function print_log() {
echo -e " • $1" echo -e " ${BLUE}->${DEFAULT} ${1}"
} }
function ask_prompt() { function ask_prompt() {
read -p "${BOLD}${1} (y/n): ${NORMAL}" -n 1 -r read -p "${BOLD}${BLUE}::${DEFAULT} ${1} [Y/n] ${RESET}" -n 1 -r
echo "" echo ""
if [[ ${REPLY} =~ ^[^yY]$ ]]; then if [[ ${REPLY} =~ ^[^yY]$ ]]; then