From 1117869e971f03e12a12e980883e052200a7cd82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Roberto=20S=C3=A1nchez?= Date: Mon, 24 Oct 2022 23:31:23 -0600 Subject: [PATCH 1/9] Adds fedora derivatives support --- setup.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/setup.sh b/setup.sh index 86a778a..5a5c81a 100755 --- a/setup.sh +++ b/setup.sh @@ -31,9 +31,15 @@ installDepend(){ ## Check for dependencies. DEPENDENCIES='autojump bash bash-completion' echo -e "${YELLOW}Installing dependencies...${RC}" - sudo dpkg --configure -a - sudo apt-get install -fyq ${DEPENDENCIES} - sudo dpkg --configure -a + if [[ -x "/usr/bin/apt-get" ]]; then + sudo dpkg --configure -a + sudo apt-get install -fyq ${DEPENDENCIES} + sudo dpkg --configure -a + elif [[ -x "/usr/bin/yum" ]]; then + sudo yum install -fyq ${DEPENDENCIES} + else + echo "Can't check the package manager to use" + fi } installStarship(){ From f4f69616ee0600348ec0a0a9d095453b436e2b60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Roberto=20S=C3=A1nchez?= Date: Mon, 24 Oct 2022 23:39:28 -0600 Subject: [PATCH 2/9] Checks if starship is already installed --- setup.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/setup.sh b/setup.sh index 86a778a..fadb91f 100755 --- a/setup.sh +++ b/setup.sh @@ -37,6 +37,12 @@ installDepend(){ } installStarship(){ + STARSHIP_CMD==$(which starship) + if [[ ! -z $STARSHIP_CMD ]]; then + echo "Starship already installed" + exit 0; + fi + if ! curl -sS https://starship.rs/install.sh|sh;then echo -e "${RED}Something went wrong during starship install!${RC}" exit 1 From 98b5b294967ab1ec818429e4c45c9bdc0ea38553 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Roberto=20S=C3=A1nchez?= Date: Mon, 24 Oct 2022 23:43:31 -0600 Subject: [PATCH 3/9] Use return instead of exit 0 --- setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.sh b/setup.sh index fadb91f..a1fd516 100755 --- a/setup.sh +++ b/setup.sh @@ -40,7 +40,7 @@ installStarship(){ STARSHIP_CMD==$(which starship) if [[ ! -z $STARSHIP_CMD ]]; then echo "Starship already installed" - exit 0; + return fi if ! curl -sS https://starship.rs/install.sh|sh;then From fb4c133cff82814990e28285a0189288d6f29791 Mon Sep 17 00:00:00 2001 From: fearlessgeekmedia Date: Fri, 28 Oct 2022 12:36:16 -0400 Subject: [PATCH 4/9] Created a setup script for Arch and Arch-based distributions --- setup-arch.sh | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100755 setup-arch.sh diff --git a/setup-arch.sh b/setup-arch.sh new file mode 100755 index 0000000..cc63638 --- /dev/null +++ b/setup-arch.sh @@ -0,0 +1,68 @@ +#!/bin/bash + +RC='\e[0m' +RED='\e[31m' +YELLOW='\e[33m' +GREEN='\e[32m' + +checkEnv(){ + ## Check if the current directory is writable. + GITPATH="$(dirname "$(realpath "$0")")" + if [[ ! -w ${GITPATH} ]];then + echo -e "${RED}Can't write to ${GITPATH}${RC}" + exit 1 + fi + + ## Check for requirements. + REQUIREMENTS='curl yay groups sudo' + if ! which ${REQUIREMENTS}>/dev/null;then + echo -e "${RED}To run me,https://github.com/fearlessgeekmedia/mybash you need: ${REQUIREMENTS}${RC}" + exit 1 + fi + + ## Check if member of the sudo group. + if ! groups|grep wheel>/dev/null;then + echo -e "${RED}You need to be a member of the sudo wheel to run me!" + exit 1 + fi +} + +installDepend(){ + ## Check for dependencies. + DEPENDENCIES='autojump bash bash-completion' + echo -e "${YELLOW}Installing dependencies...${RC}" + sudo yay -S ${DEPENDENCIES} +} + +installStarship(){ + if ! curl -sS https://starship.rs/install.sh|sh;then + echo -e "${RED}Something went wrong during starship install!${RC}" + exit 1 + fi +} + +linkConfig(){ + ## Check if a bashrc file is already there. + OLD_BASHRC="${HOME}/.bashrc" + if [[ -e ${OLD_BASHRC} ]];then + echo -e "${YELLOW}Moving old bash config file to ${HOME}/.bashrc.bak${RC}" + if ! mv ${OLD_BASHRC} ${HOME}/.bashrc.bak;then + echo -e "${RED}Can't move the old bash config file!${RC}" + exit 1 + fi + fi + + echo -e "${YELLOW}Linking new bash config file...${RC}" + ## Make symbolic link. + ln -svf ${GITPATH}/.bashrc ${HOME}/.bashrc + ln -svf ${GITPATH}/starship.toml ${HOME}/.config/starship.toml +} + +checkEnv +installDepend +installStarship +if linkConfig;then + echo -e "${GREEN}Done!\nrestart your shell to see the changes.${RC}" +else + echo -e "${RED}Something went wrong!${RC}" +fi From 258e1504e53f594577ac906bb5a6f0581f3d039e Mon Sep 17 00:00:00 2001 From: fearlessgeekmedia Date: Fri, 28 Oct 2022 13:09:08 -0400 Subject: [PATCH 5/9] fixed problems in the mybash arch install script I made --- setup-arch.sh | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/setup-arch.sh b/setup-arch.sh index cc63638..4c88833 100755 --- a/setup-arch.sh +++ b/setup-arch.sh @@ -14,24 +14,31 @@ checkEnv(){ fi ## Check for requirements. - REQUIREMENTS='curl yay groups sudo' + REQUIREMENTS='curl yay sudo' if ! which ${REQUIREMENTS}>/dev/null;then echo -e "${RED}To run me,https://github.com/fearlessgeekmedia/mybash you need: ${REQUIREMENTS}${RC}" exit 1 fi - ## Check if member of the sudo group. + ## Check if member of the wheel group. if ! groups|grep wheel>/dev/null;then - echo -e "${RED}You need to be a member of the sudo wheel to run me!" + echo -e "${RED}You need to be a member of the wheel to run me!" exit 1 fi } installDepend(){ ## Check for dependencies. - DEPENDENCIES='autojump bash bash-completion' + # For some reason, if I put autojump in the original DEPENCENCIES variable, + # it skips the installation and just does bash and bash completion. So I + # put autojump in a separate variable and separate yay command. + DEPENDENCIES1='bash bash-completion' + DEPENDENCIES2='autojump' echo -e "${YELLOW}Installing dependencies...${RC}" - sudo yay -S ${DEPENDENCIES} + yay -S ${DEPENDENCIES1} + yay -S ${DEPENDENCIES2} + sudo mkdir /usr/local/bin/autojump + sudo ln -s /etc/profile.d/autojump.sh /usr/share/autojump/autojump.sh } installStarship(){ From 50d9d5945fe86831a633f3a6ca4188769a423415 Mon Sep 17 00:00:00 2001 From: Robin Stevens Date: Mon, 31 Oct 2022 09:39:31 +0100 Subject: [PATCH 6/9] typo --- setup-arch.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup-arch.sh b/setup-arch.sh index 4c88833..9f0ee16 100755 --- a/setup-arch.sh +++ b/setup-arch.sh @@ -29,7 +29,7 @@ checkEnv(){ installDepend(){ ## Check for dependencies. - # For some reason, if I put autojump in the original DEPENCENCIES variable, + # For some reason, if I put autojump in the original DEPENDENCIES variable, # it skips the installation and just does bash and bash completion. So I # put autojump in a separate variable and separate yay command. DEPENDENCIES1='bash bash-completion' From 8853a0f85ade8b1dc45a462e64e253b9c3d98b9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Roberto=20S=C3=A1nchez?= Date: Fri, 4 Nov 2022 02:46:43 -0600 Subject: [PATCH 7/9] Added CheckEnv for package manager. Tar and neovim are needed. --- .bashrc | 9 ++++++++- setup.sh | 14 +++++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/.bashrc b/.bashrc index 4a23f35..3489375 100644 --- a/.bashrc +++ b/.bashrc @@ -601,4 +601,11 @@ eval "$(starship init bash)" #Autojump -. /usr/share/autojump/autojump.sh +if [ -f "/usr/share/autojump/autojump.sh" ]; then + . /usr/share/autojump/autojump.sh +elif [ -f "/usr/share/autojump/autojump.bash" ]; then + . /usr/share/autojump/autojump.bash +else + echo "can't found the autojump script" +fi + diff --git a/setup.sh b/setup.sh index 5a5c81a..94fbe90 100755 --- a/setup.sh +++ b/setup.sh @@ -14,7 +14,7 @@ checkEnv(){ fi ## Check for requirements. - REQUIREMENTS='curl apt groups sudo' + REQUIREMENTS='curl groups sudo' if ! which ${REQUIREMENTS}>/dev/null;then echo -e "${RED}To run me, you need: ${REQUIREMENTS}${RC}" exit 1 @@ -25,20 +25,24 @@ checkEnv(){ echo -e "${RED}You need to be a member of the sudo group to run me!" exit 1 fi + + if [[ ! -x "/usr/bin/apt-get" ]] || [[ ! -x "/usr/bin/yum" ]]; then + echo -e "Can't find a supported package manager" + exit 1 + fi + } installDepend(){ ## Check for dependencies. - DEPENDENCIES='autojump bash bash-completion' + DEPENDENCIES='autojump bash bash-completion tar neovim' echo -e "${YELLOW}Installing dependencies...${RC}" if [[ -x "/usr/bin/apt-get" ]]; then sudo dpkg --configure -a sudo apt-get install -fyq ${DEPENDENCIES} sudo dpkg --configure -a elif [[ -x "/usr/bin/yum" ]]; then - sudo yum install -fyq ${DEPENDENCIES} - else - echo "Can't check the package manager to use" + sudo yum install -yq ${DEPENDENCIES} fi } From b31eeb243965d33ce44f980acb7ad480abf57931 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Roberto=20S=C3=A1nchez?= Date: Fri, 4 Nov 2022 02:48:10 -0600 Subject: [PATCH 8/9] Wrong operator. Fixed --- setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.sh b/setup.sh index 94fbe90..960b4c5 100755 --- a/setup.sh +++ b/setup.sh @@ -26,7 +26,7 @@ checkEnv(){ exit 1 fi - if [[ ! -x "/usr/bin/apt-get" ]] || [[ ! -x "/usr/bin/yum" ]]; then + if [[ ! -x "/usr/bin/apt-get" ]] && [[ ! -x "/usr/bin/yum" ]]; then echo -e "Can't find a supported package manager" exit 1 fi From dee399a4a8bd5470b266c03d3837eb259aee6762 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Roberto=20S=C3=A1nchez?= Date: Fri, 4 Nov 2022 03:04:34 -0600 Subject: [PATCH 9/9] Adds dnf just in case yum will get removed in a future --- setup.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/setup.sh b/setup.sh index 960b4c5..dc1e618 100755 --- a/setup.sh +++ b/setup.sh @@ -26,7 +26,7 @@ checkEnv(){ exit 1 fi - if [[ ! -x "/usr/bin/apt-get" ]] && [[ ! -x "/usr/bin/yum" ]]; then + if [[ ! -x "/usr/bin/apt-get" ]] && [[ ! -x "/usr/bin/yum" ]] && [[ ! -x "/usr/bin/dnf" ]]; then echo -e "Can't find a supported package manager" exit 1 fi @@ -43,6 +43,8 @@ installDepend(){ sudo dpkg --configure -a elif [[ -x "/usr/bin/yum" ]]; then sudo yum install -yq ${DEPENDENCIES} + elif [[ -x "/usr/bin/dnf" ]]; then + sudo dnf install -yq ${DEPENDENCIES} fi }