Cleanup install.sh, post-install.sh and utils.sh

Signed-off-by: Severin Kaderli <severin.kaderli@gmail.com>
This commit is contained in:
Severin Kaderli 2018-12-13 22:11:20 +01:00
parent e405bbcd89
commit 3a8dd98e68
4 changed files with 33 additions and 26 deletions

View file

@ -7,8 +7,8 @@
# Severin Kaderli <severin.kaderli@gmail.com>
#
# DESCRIPTION:
# This script provides functions that I use in my other scripts. It is
# not supposed to be run directly.
# This script provides functions and variables that I use in my other scripts.
# It is not supposed to be run directly but to be sourced by other scripts.
#
# USAGE:
# Source this script in the needed script.
@ -32,7 +32,7 @@ YELLOW='\033[33m'
# Helper functions
#######################################
# Function to display fancy headers
# $1: Title
# USAGE: print_header TITLE
function print_header() {
echo -e "\n${GREEN}########################################"
echo -e "# ${1}"
@ -40,14 +40,14 @@ function print_header() {
}
# Creates the given directory in the home directory
# $1: Directory
# USAGE: create_directory DIRECTORY
function create_directory() {
echo -e "- Creating directory ${YELLOW}${HOME}/${1}${RESET}"
mkdir -p "${HOME}/${1}"
}
# Creates a symlink of the given file from the home directory to here.
# $1: Filename
# USAGE: create_link FILE
function create_link() {
echo -e "- Linking ${YELLOW}${HOME}/${1}${RESET} -> ${YELLOW}${SYSTEM_DIR}/${1}${RESET}"
rm -rf "${HOME:?}/$1"
@ -55,9 +55,7 @@ function create_link() {
}
# Function to set owner and permission of a file
# $1: Owner
# $2: Permissions
# $3: File
# USAGE: set_permission OWNER PERMISSION FILE
function set_permission() {
echo -e "- Changing permission of ${YELLOW}${3}${RESET} to ${YELLOW}${1}${RESET}"
sudo chown -R "${1}" "${3}"
@ -66,7 +64,7 @@ function set_permission() {
}
# Function to enable a service
# $1: Service
# USAGE: enable_service SERVICE
function enable_service() {
echo -e "- Enabling service ${YELLOW}${1}${RESET}"
sudo systemctl enable "${1}"