Update utils.sh
Signed-off-by: Severin Kaderli <severin.kaderli@gmail.com>
This commit is contained in:
parent
c88cf45884
commit
7bf11a5cdb
2 changed files with 13 additions and 14 deletions
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
START_DIR=$(pwd)
|
START_DIR=$(pwd)
|
||||||
|
|
||||||
|
print_header "Updating submodules"
|
||||||
|
|
||||||
|
|
||||||
while IFS= read -r -d '' dir
|
while IFS= read -r -d '' dir
|
||||||
|
|
|
@ -34,11 +34,9 @@ YELLOW='\033[33m'
|
||||||
# Function to display fancy headers
|
# Function to display fancy headers
|
||||||
# USAGE: print_header TITLE
|
# USAGE: print_header TITLE
|
||||||
function print_header() {
|
function print_header() {
|
||||||
echo -e "\n${GREEN}########################################"
|
echo -e "\n${GREEN}╔══════════════════════════════════════════════════════════════════════════════╗"
|
||||||
echo -e "#"
|
echo -e "║ $(printf "%-77s" "${1}")║"
|
||||||
echo -e "# ${1}"
|
echo -e "╚══════════════════════════════════════════════════════════════════════════════╝${RESET}"
|
||||||
echo -e "#"
|
|
||||||
echo -e "########################################${RESET}"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to print a info message with the current time and to send
|
# Function to print a info message with the current time and to send
|
||||||
|
@ -52,25 +50,26 @@ function print_notify() {
|
||||||
# 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}${1}"
|
echo -e "${YELLOW}┌──────────────────────────────────────────────────────────────────────────────┐"
|
||||||
echo -e "----------------------------------------${RESET}"
|
echo -e "│ $(printf "%-77s" "${1}")│"
|
||||||
|
echo -e "└──────────────────────────────────────────────────────────────────────────────┘${RESET}"
|
||||||
}
|
}
|
||||||
|
|
||||||
function print_log() {
|
function print_log() {
|
||||||
echo -e "- $1"
|
echo -e "• $1"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Creates the given directory in the home directory
|
# Creates the given directory in the home directory
|
||||||
# USAGE: create_directory DIRECTORY
|
# USAGE: create_directory DIRECTORY
|
||||||
function create_directory() {
|
function create_directory() {
|
||||||
echo -e "- Creating directory ${YELLOW}${HOME}/${1}${RESET}"
|
print_log "Creating directory ${YELLOW}${HOME}/${1}${RESET}"
|
||||||
mkdir -p "${HOME}/${1}"
|
mkdir -p "${HOME}/${1}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Creates a symlink of the given file from the home directory to here.
|
# Creates a symlink of the given file from the home directory to here.
|
||||||
# USAGE: create_link FILE
|
# USAGE: create_link FILE
|
||||||
function create_link() {
|
function create_link() {
|
||||||
echo -e "- Linking ${YELLOW}${HOME}/${1}${RESET} -> ${YELLOW}${SYSTEM_DIR}/${1}${RESET}"
|
print_log "Linking ${YELLOW}${HOME}/${1}${RESET} -> ${YELLOW}${SYSTEM_DIR}/${1}${RESET}"
|
||||||
rm -rf "${HOME:?}/$1"
|
rm -rf "${HOME:?}/$1"
|
||||||
ln -fs "${SYSTEM_DIR}/${1}" "${HOME}/${1}"
|
ln -fs "${SYSTEM_DIR}/${1}" "${HOME}/${1}"
|
||||||
}
|
}
|
||||||
|
@ -78,15 +77,15 @@ function create_link() {
|
||||||
# Function to set owner and permission of a file
|
# Function to set owner and permission of a file
|
||||||
# USAGE: set_permission OWNER PERMISSION FILE
|
# USAGE: set_permission OWNER PERMISSION FILE
|
||||||
function set_permission() {
|
function set_permission() {
|
||||||
echo -e "- Changing permission of ${YELLOW}${3}${RESET} to ${YELLOW}${1}${RESET}"
|
print_log "Changing owner of ${YELLOW}${3}${RESET} to ${YELLOW}${1}${RESET}"
|
||||||
sudo chown -R "${1}" "${3}"
|
sudo chown -R "${1}" "${3}"
|
||||||
echo -e "- Changing permission of ${YELLOW}${3}${RESET} to ${YELLOW}${2}${RESET}"
|
print_log "Changing permission of ${YELLOW}${3}${RESET} to ${YELLOW}${2}${RESET}"
|
||||||
sudo chmod -R "${2}" "${3}"
|
sudo chmod -R "${2}" "${3}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to enable a service
|
# Function to enable a service
|
||||||
# USAGE: enable_service SERVICE
|
# USAGE: enable_service SERVICE
|
||||||
function enable_service() {
|
function enable_service() {
|
||||||
echo -e "- Enabling service ${YELLOW}${1}${RESET}"
|
print_log "Enabling service ${YELLOW}${1}${RESET}"
|
||||||
sudo systemctl enable "${1}"
|
sudo systemctl enable "${1}"
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue