Merge branch 'install' of https://github.com/andrejusk/dotfiles
Clean scripts, remove sudo requirement Add python dependencies Correctly symlink and add poetry Update make clean Add python2 to dependencies Fix pyenv install Use pyenv to install python Update .gitignore Install git and keybase
This commit is contained in:
73
install.sh
73
install.sh
@@ -1,47 +1,48 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Runs all install scripts
|
||||
# Invokes all install scripts.
|
||||
#
|
||||
|
||||
# set -xv
|
||||
set -o pipefail
|
||||
# Log execution
|
||||
printf "Installing ${C_CYAN}$repository${C_NC}"
|
||||
printf " as ${C_YELLOW}$USER${C_NC}\n\n"
|
||||
|
||||
dir=`dirname $0`
|
||||
name=`basename $0 ".sh"`
|
||||
source $dir/utils.sh
|
||||
printf "${C_CYAN}andrejusk/dotfiles${C_NC}\n\n"
|
||||
|
||||
# Check if running
|
||||
lock_file=$dir/$name.lock
|
||||
if [ -f $lock_file ]; then
|
||||
printf "${C_RED}Script already running${C_NC}\n"
|
||||
exit 1
|
||||
else
|
||||
touch $lock_file # Requires clear
|
||||
fi
|
||||
|
||||
# Check for root
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
printf "${C_RED}Called without sudo, run:${C_NC}\n"
|
||||
printf "sudo !!\n\n"
|
||||
make clear
|
||||
# Prevent running as root
|
||||
if [ "$USER" == "root" ]; then
|
||||
printf "Failed: ${C_RED}Running as $USER${C_NC}\n"
|
||||
printf "Please run as user, not ${C_YELLOW}sudo${C_NC}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Prevent concurrent scripts
|
||||
lock_file="$dotfiles_dir/.$lock_extension"
|
||||
if [ -f "$lock_file" ]; then
|
||||
printf "Failed: ${C_RED}Script already running${C_NC}\n"
|
||||
printf "Please wait for script to exit or ${C_YELLOW}make clean${C_NC}\n"
|
||||
exit 1
|
||||
fi
|
||||
touch $lock_file # Requires clear
|
||||
|
||||
# Run all install scripts
|
||||
install_dir="$dir/install"
|
||||
for script in $install_dir/*.sh;
|
||||
do
|
||||
script_name=`basename $script ".sh"`
|
||||
script_lock="$install_dir/$script_name.lock"
|
||||
if [ -f $script_lock ]; then
|
||||
printf "skipping $script_name\n"
|
||||
else
|
||||
printf "running $script_name\n"
|
||||
touch $script_lock
|
||||
bash -o pipefail $script | indent
|
||||
fi
|
||||
for script in "$dotfiles_dir/install/*.sh"; do
|
||||
|
||||
printf "$script\n\n"
|
||||
|
||||
# Avoid pattern matching self
|
||||
[ -e "$script" ] || continue
|
||||
|
||||
# Log execution
|
||||
script_name=$(basename "$script" ".sh")
|
||||
printf "Running ${C_YELLOW}$script_name${C_NC}...\n${C_DGRAY}"
|
||||
|
||||
# Run and indent output
|
||||
source "$script" | indent
|
||||
printf "${C_NC}\n"
|
||||
|
||||
done
|
||||
|
||||
# Exit
|
||||
make clear
|
||||
# Clean up and exit
|
||||
printf "Done! Cleaning up...\n${C_DGRAY}"
|
||||
make clean
|
||||
printf "${C_NC}\n"
|
||||
exit 0
|
||||
|
||||
Reference in New Issue
Block a user