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

@ -5,6 +5,6 @@ before_script:
Lint:
script:
- shellcheck -x ./system/bin/*
- shellcheck -x disable=SC2034 ./system/bin/*
- shellcheck -x ./install.sh
- shellcheck -x ./post-install.sh

View file

@ -1,7 +1,18 @@
#!/bin/bash
#
# SCRIPT NAME:
# install.sh
#
# Author: Severin Kaderli <severin.kaderli@gmail.com>
# Usage: ./install.sh
# AUTHOR:
# Severin Kaderli <severin.kaderli@gmail.com>
#
# DESCRIPTION:
# This is the main installation script for my dotfiles. It setups the symlinks
# to the neeeded files, creates new directories, enables systemd services,
# installs pacman packages and gives out the correct permissions to files.
#
# USAGE:
# ./install.sh
. ./system/bin/utils.sh
#######################################
@ -9,10 +20,10 @@
#######################################
# Array of directories which should be created
DIRECTORIES=(
".logs"
"Build"
"Downloads"
"Projects"
".logs"
)
# Array of files which should be symlinked in the home folder
@ -54,7 +65,6 @@ SYSTEMD_SERVICES=(
#######################################
# Main code
#######################################
# Creating needed directories
print_header "Creating directories"
for dir in "${DIRECTORIES[@]}"
do
@ -76,17 +86,12 @@ print_header "Installing packages"
#aurman -S --noconfirm $(cat "${PACKAGES_DIR}/packages.list")
#aurman -S --noconfirm $(cat "${PACKAGES_DIR}/packages2.list")
# Create symlinks to dotfiles
print_header "Creating symlinks"
for file in "${LINKED_FILES_HOME[@]}"
do
create_link "${file}"
done
print_header "Asking for root permissions"
sudo -v
# Give scripts execute permissions
print_header "Give permissions"
set_permission severin 744 "${HOME}/bin"

View file

@ -1,13 +1,18 @@
#!/bin/bash
#
# SCRIPT NAME:
# post-install.sh
#
# This is the post installation script. This should be executed only after
# install.sh has been executed completly and the system has been rebooted
# after that.
# AUTHOR:
# Severin Kaderli <severin.kaderli@gmail.com>
#
# This script installs npm packages.
# DESCRIPTION:
# This is the post-install script for my dotfiles. It should be only run
# after install.sh has been run and the system has been rebooted. This script
# installs global npm packages.
#
# Author: Severin Kaderli <severin.kaderli@gmail.com>
# Usage: ./post-install.sh
# USAGE:
# ./post-install.sh
. ./system/bin/utils.sh
#######################################
@ -23,6 +28,5 @@ NPM_PACKAGES=(
#######################################
# Main code
#######################################
# Install global npm packages
print_header "Installing global npm packages"
npm i -g "${NPM_PACKAGES[@]}"

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}"