From 5bf4a0ce677d309c5400e3caf0da26d4e0d2326e Mon Sep 17 00:00:00 2001 From: Santiago Lo Coco Date: Wed, 22 Dec 2021 13:31:22 -0300 Subject: [PATCH] Update scripts (sudo per command and more changes) --- README.md | 17 +++++++++++------ scripts/bootstrap.sh | 23 +++++++++++++++-------- scripts/install.sh | 2 +- scripts/linkFiles.sh | 8 ++------ 4 files changed, 29 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 205d2a9..d97564b 100644 --- a/README.md +++ b/README.md @@ -3,10 +3,13 @@ [Fork][1] this repository and you will be able to backup all your dotfiles (and easily install them on another machine). ## Table of contents -- [Installation ](#installation-) -- [Usage ](#usage-) -- [Contributing ](#contributing-) -- [License ](#license-) +- [CocoRice](#cocorice) + - [Table of contents](#table-of-contents) + - [Installation ](#installation-) + - [Usage ](#usage-) + - [Dependencies ](#dependencies-) + - [Contributing ](#contributing-) + - [License ](#license-) ## Installation @@ -17,10 +20,12 @@ Fork or clone this repo. Run ```bash -sudo ./scripts/bootstrap.sh +sh scripts/bootstrap.sh ``` -Note that because this script will create symbolic links to the dotfiles in this repository, you must not delete it. +## Dependencies + +You must install dialog. ## Contributing PRs are welcome. diff --git a/scripts/bootstrap.sh b/scripts/bootstrap.sh index 8e0335c..9013af6 100755 --- a/scripts/bootstrap.sh +++ b/scripts/bootstrap.sh @@ -23,14 +23,21 @@ getGitconfigData() { } checkForDependencies() { - unameOutput=$(uname -a | grep "arch") - if [ -f "/etc/arch-release" ] || [ $unameOutput -eq 0 ]; then - pacman --noconfirm --needed -Sy dialog > /dev/null 2>&1 || echo "You must run this script as root and have an active internet connection." >&2 || exit 1 - fi - commOuput=$(command -v dialog &> /dev/null) if [ $? -eq 1 ]; then - echo "You must install dialog." >&2 || exit 1 + unameOutput=$(uname -a | grep "arch") + if [ -f "/etc/arch-release" ] || [ $unameOutput -eq 0 ]; then + sudo pacman --noconfirm --needed -Sy dialog > /dev/null 2>&1 + if [ $? -eq 1 ]; then + echo "You must run this script as root and have an active internet connection." >&2 + exit 1 + fi + + return + fi + + echo "You must install dialog." >&2 + exit 1 fi } @@ -43,8 +50,8 @@ startRice() { dialog --title "CocoRice" --msgbox "Hi! This script will auto install my dotfiles. Make sure to backup your dotfiles!" 10 60 getGitconfigData - ./scripts/linkFiles.sh - # ./scripts/install.sh + sh scripts/linkFiles.sh + # sh scripts/install.sh dialog --title "CocoRice" --msgbox "All done! Enjoy..." 10 60 clear diff --git a/scripts/install.sh b/scripts/install.sh index e36f9ef..3dc3de7 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -2,7 +2,7 @@ makeInstall() { cd $1 - make install + sudo make install cd .. } diff --git a/scripts/linkFiles.sh b/scripts/linkFiles.sh index 5e1940b..42b83bf 100755 --- a/scripts/linkFiles.sh +++ b/scripts/linkFiles.sh @@ -15,7 +15,8 @@ linkFile() { ln -s "$1" "$2" else selectedOption=$(dialog --menu "File already exists: $(basename "$1"), what would you like to do?" 10 60 0 1 "Skip" 2 "Skip all" 3 "Overwrite" 4 "Overwrite all" 5 "Backup" 6 "Backup all" 3>&1 1>&2 2>&3 3>&1) - if [ "$selectedOption" = "" ]; then + if [ $? -eq 1 ]; then + # if [ "$selectedOption" = "" ]; then exit 0 fi @@ -44,9 +45,6 @@ linkFile() { } loopThroughFiles() { - # lastFolder=$(pwd -P) - - # DOTFILES=$(echo "$(pwd -P)" | awk '{ sub(/CocoRice.*/, "CocoRice"); print }') DOTFILES=$(pwd -P) cd $DOTFILES @@ -82,8 +80,6 @@ loopThroughFiles() { fi done done - - # cd $lastFolder } loopThroughFiles \ No newline at end of file