Cleanup install.sh, post-install.sh and utils.sh
Signed-off-by: Severin Kaderli <severin.kaderli@gmail.com>
This commit is contained in:
parent
e405bbcd89
commit
3a8dd98e68
4 changed files with 33 additions and 26 deletions
|
@ -5,6 +5,6 @@ before_script:
|
||||||
|
|
||||||
Lint:
|
Lint:
|
||||||
script:
|
script:
|
||||||
- shellcheck -x ./system/bin/*
|
- shellcheck -x disable=SC2034 ./system/bin/*
|
||||||
- shellcheck -x ./install.sh
|
- shellcheck -x ./install.sh
|
||||||
- shellcheck -x ./post-install.sh
|
- shellcheck -x ./post-install.sh
|
||||||
|
|
23
install.sh
23
install.sh
|
@ -1,7 +1,18 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
#
|
#
|
||||||
# Author: Severin Kaderli <severin.kaderli@gmail.com>
|
# SCRIPT NAME:
|
||||||
# Usage: ./install.sh
|
# 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
|
. ./system/bin/utils.sh
|
||||||
|
|
||||||
#######################################
|
#######################################
|
||||||
|
@ -9,10 +20,10 @@
|
||||||
#######################################
|
#######################################
|
||||||
# Array of directories which should be created
|
# Array of directories which should be created
|
||||||
DIRECTORIES=(
|
DIRECTORIES=(
|
||||||
|
".logs"
|
||||||
"Build"
|
"Build"
|
||||||
"Downloads"
|
"Downloads"
|
||||||
"Projects"
|
"Projects"
|
||||||
".logs"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Array of files which should be symlinked in the home folder
|
# Array of files which should be symlinked in the home folder
|
||||||
|
@ -54,7 +65,6 @@ SYSTEMD_SERVICES=(
|
||||||
#######################################
|
#######################################
|
||||||
# Main code
|
# Main code
|
||||||
#######################################
|
#######################################
|
||||||
# Creating needed directories
|
|
||||||
print_header "Creating directories"
|
print_header "Creating directories"
|
||||||
for dir in "${DIRECTORIES[@]}"
|
for dir in "${DIRECTORIES[@]}"
|
||||||
do
|
do
|
||||||
|
@ -76,17 +86,12 @@ print_header "Installing packages"
|
||||||
#aurman -S --noconfirm $(cat "${PACKAGES_DIR}/packages.list")
|
#aurman -S --noconfirm $(cat "${PACKAGES_DIR}/packages.list")
|
||||||
#aurman -S --noconfirm $(cat "${PACKAGES_DIR}/packages2.list")
|
#aurman -S --noconfirm $(cat "${PACKAGES_DIR}/packages2.list")
|
||||||
|
|
||||||
# Create symlinks to dotfiles
|
|
||||||
print_header "Creating symlinks"
|
print_header "Creating symlinks"
|
||||||
for file in "${LINKED_FILES_HOME[@]}"
|
for file in "${LINKED_FILES_HOME[@]}"
|
||||||
do
|
do
|
||||||
create_link "${file}"
|
create_link "${file}"
|
||||||
done
|
done
|
||||||
|
|
||||||
print_header "Asking for root permissions"
|
|
||||||
sudo -v
|
|
||||||
|
|
||||||
# Give scripts execute permissions
|
|
||||||
print_header "Give permissions"
|
print_header "Give permissions"
|
||||||
set_permission severin 744 "${HOME}/bin"
|
set_permission severin 744 "${HOME}/bin"
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,18 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
#
|
#
|
||||||
# This is the post installation script. This should be executed only after
|
# SCRIPT NAME:
|
||||||
# install.sh has been executed completly and the system has been rebooted
|
# post-install.sh
|
||||||
# after that.
|
|
||||||
#
|
#
|
||||||
# This script installs npm packages.
|
# AUTHOR:
|
||||||
|
# Severin Kaderli <severin.kaderli@gmail.com>
|
||||||
#
|
#
|
||||||
# Author: Severin Kaderli <severin.kaderli@gmail.com>
|
# DESCRIPTION:
|
||||||
# Usage: ./post-install.sh
|
# 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.
|
||||||
|
#
|
||||||
|
# USAGE:
|
||||||
|
# ./post-install.sh
|
||||||
. ./system/bin/utils.sh
|
. ./system/bin/utils.sh
|
||||||
|
|
||||||
#######################################
|
#######################################
|
||||||
|
@ -23,6 +28,5 @@ NPM_PACKAGES=(
|
||||||
#######################################
|
#######################################
|
||||||
# Main code
|
# Main code
|
||||||
#######################################
|
#######################################
|
||||||
# Install global npm packages
|
|
||||||
print_header "Installing global npm packages"
|
print_header "Installing global npm packages"
|
||||||
npm i -g "${NPM_PACKAGES[@]}"
|
npm i -g "${NPM_PACKAGES[@]}"
|
|
@ -7,8 +7,8 @@
|
||||||
# Severin Kaderli <severin.kaderli@gmail.com>
|
# Severin Kaderli <severin.kaderli@gmail.com>
|
||||||
#
|
#
|
||||||
# DESCRIPTION:
|
# DESCRIPTION:
|
||||||
# This script provides functions that I use in my other scripts. It is
|
# This script provides functions and variables that I use in my other scripts.
|
||||||
# not supposed to be run directly.
|
# It is not supposed to be run directly but to be sourced by other scripts.
|
||||||
#
|
#
|
||||||
# USAGE:
|
# USAGE:
|
||||||
# Source this script in the needed script.
|
# Source this script in the needed script.
|
||||||
|
@ -32,7 +32,7 @@ YELLOW='\033[33m'
|
||||||
# Helper functions
|
# Helper functions
|
||||||
#######################################
|
#######################################
|
||||||
# Function to display fancy headers
|
# Function to display fancy headers
|
||||||
# $1: Title
|
# USAGE: print_header TITLE
|
||||||
function print_header() {
|
function print_header() {
|
||||||
echo -e "\n${GREEN}########################################"
|
echo -e "\n${GREEN}########################################"
|
||||||
echo -e "# ${1}"
|
echo -e "# ${1}"
|
||||||
|
@ -40,14 +40,14 @@ function print_header() {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Creates the given directory in the home directory
|
# Creates the given directory in the home directory
|
||||||
# $1: Directory
|
# USAGE: create_directory DIRECTORY
|
||||||
function create_directory() {
|
function create_directory() {
|
||||||
echo -e "- Creating directory ${YELLOW}${HOME}/${1}${RESET}"
|
echo -e "- 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.
|
||||||
# $1: Filename
|
# USAGE: create_link FILE
|
||||||
function create_link() {
|
function create_link() {
|
||||||
echo -e "- Linking ${YELLOW}${HOME}/${1}${RESET} -> ${YELLOW}${SYSTEM_DIR}/${1}${RESET}"
|
echo -e "- Linking ${YELLOW}${HOME}/${1}${RESET} -> ${YELLOW}${SYSTEM_DIR}/${1}${RESET}"
|
||||||
rm -rf "${HOME:?}/$1"
|
rm -rf "${HOME:?}/$1"
|
||||||
|
@ -55,9 +55,7 @@ function create_link() {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to set owner and permission of a file
|
# Function to set owner and permission of a file
|
||||||
# $1: Owner
|
# USAGE: set_permission OWNER PERMISSION FILE
|
||||||
# $2: Permissions
|
|
||||||
# $3: File
|
|
||||||
function set_permission() {
|
function set_permission() {
|
||||||
echo -e "- Changing permission of ${YELLOW}${3}${RESET} to ${YELLOW}${1}${RESET}"
|
echo -e "- Changing permission of ${YELLOW}${3}${RESET} to ${YELLOW}${1}${RESET}"
|
||||||
sudo chown -R "${1}" "${3}"
|
sudo chown -R "${1}" "${3}"
|
||||||
|
@ -66,7 +64,7 @@ function set_permission() {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to enable a service
|
# Function to enable a service
|
||||||
# $1: Service
|
# USAGE: enable_service SERVICE
|
||||||
function enable_service() {
|
function enable_service() {
|
||||||
echo -e "- Enabling service ${YELLOW}${1}${RESET}"
|
echo -e "- Enabling service ${YELLOW}${1}${RESET}"
|
||||||
sudo systemctl enable "${1}"
|
sudo systemctl enable "${1}"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue