@@ -23,7 +23,7 @@ script_run_as_root(){
2323# Install git
2424install_git () {
2525 # Check the os distribution ubuntu/debian/rhel/fedora/centos
26- os_distribution=$( grep ^HOME_URL /etc/os-release | awk -F' [/.]' ' {print $(NF-2)}' )
26+ os_distribution=$( awk -F' [/.]' ' /^HOME_URL/ {print $(NF-2)}' /etc/os-release )
2727 if command -v git & > /dev/null; then
2828 echo -e " \033[30m===>\033[0m \033[32mGit is already installed. \033[0m"
2929 echo
@@ -70,33 +70,33 @@ installer_script_usage() {
7070git_clone_function (){
7171 code_location=$1
7272 github_account=$2
73- cd ${code_location} && [[ $( pwd) != " ${code_location} " ]] && cd ${code_location}
74- echo -e " \033[30m===>\033[0m \033[32mDownloading OpenEMR repository... \033[0m"
75- echo
76- # For openemr repos
77- git clone https://github.com/${github_account} /openemr.git
78- cd ${code_location} /openemr && [[ $( pwd) != " ${code_location} /openemr" ]] && cd ${code_location} /openemr
79- git remote add upstream https://github.com/openemr/openemr.git
80- git fetch upstream
81- echo
82- echo -e " \033[30m===>\033[0m \033[32mPulling the latest data... \033[0m"
83- echo
84- git pull upstream master
85- echo
73+ (
74+ set -euo pipefail
75+ cd -P " ${code_location} "
76+ echo -e " \033[30m===>\033[0m \033[32mDownloading OpenEMR repository... \033[0m"
77+ echo
78+ # For openemr repos
79+ git clone https://github.com/${github_account} /openemr.git
80+ git -C openemr remote add upstream https://github.com/openemr/openemr.git
81+ git -C openemr fetch upstream
82+ echo
83+ echo -e " \033[30m===>\033[0m \033[32mPulling the latest data... \033[0m"
84+ echo
85+ git -C openemr pull upstream master
86+ echo
8687
87- # For openemr-devops repos
88- cd ${code_location} && [[ $( pwd) != " ${code_location} " ]] && cd ${code_location}
89- echo -e " \033[30m===>\033[0m \033[32mDownloading OpenEMR-devops repository... \033[0m"
90- echo
91- git clone https://github.com/${github_account} /openemr-devops.git
92- cd ${code_location} /openemr-devops && [[ $( pwd) != " ${code_location} /openemr-devops" ]] && cd ${code_location} /openemr-devops
93- git remote add upstream https://github.com/openemr/openemr-devops.git
94- git fetch upstream
95- echo
96- echo -e " \033[30m===>\033[0m \033[32mPulling the latest data... \033[0m"
97- echo
98- git pull upstream master
99- echo
88+ # For openemr-devops repos
89+ echo -e " \033[30m===>\033[0m \033[32mDownloading OpenEMR-devops repository... \033[0m"
90+ echo
91+ git clone https://github.com/${github_account} /openemr-devops.git
92+ git -C openemr-devops remote add upstream https://github.com/openemr/openemr-devops.git
93+ git -C openemr-devops fetch upstream
94+ echo
95+ echo -e " \033[30m===>\033[0m \033[32mPulling the latest data... \033[0m"
96+ echo
97+ git -C openemr-devops pull upstream master
98+ echo
99+ )
100100}
101101
102102# Check the code clone or not
@@ -143,7 +143,7 @@ rhel_register_check_and_enable_repo() {
143143 register_note
144144 fi
145145 elif [[ -f ${register_lock} ]]; then
146- if [[ " $( cat /tmp/openemr-register-lock) " = " 1" ]]; then
146+ if [[ " $( < /tmp/openemr-register-lock) " = " 1" ]]; then
147147 register_note
148148 fi
149149 fi
@@ -157,7 +157,8 @@ rhel_register_check_and_enable_repo() {
157157 subscription-manager repos --enable rhel-7-server-extras-rpms & > /dev/null
158158 [[ $? -eq 0 ]] && echo 2 >> ${repo_lock}
159159 elif [[ -f ${repo_lock} ]]; then
160- if [[ " $( cat /tmp/openemr-repo-lock| wc -l) " = " 2" ]]; then
160+ line_count=$( wc -l < /tmp/openemr-repo-lock)
161+ if [[ " ${line_count} " = " 2" ]]; then
161162 echo -e " \033[30m===>\033[0m \033[32mBoth of base and extras repo are already enabled. \033[0m"
162163 echo
163164 fi
@@ -187,7 +188,8 @@ install_docker() {
187188 sudo curl -fsSL https://download.docker.com/linux/${os_distribution} /gpg | sudo apt-key add -
188189 echo
189190 echo -e " \033[30m===>\033[0m \033[32mSetting up the stable repository... \033[0m"
190- sudo add-apt-repository " deb [arch=amd64] https://download.docker.com/linux/${os_distribution} $( lsb_release -cs) stable"
191+ codename=$( lsb_release -cs)
192+ sudo add-apt-repository " deb [arch=amd64] https://download.docker.com/linux/${os_distribution} ${codename} stable"
191193 echo
192194 echo -e " \033[30m===>\033[0m \033[32mInstalling docker engine... \033[0m"
193195 echo
@@ -246,7 +248,9 @@ install_docker_compose() {
246248 echo -e " \033[30m===>\033[0m \033[32mInstalling docker-compose... \033[0m"
247249 echo
248250 # Run sudo under root mode that is also fine e.g. rhel/fedora/centos
249- sudo curl -L " https://github.com/docker/compose/releases/download/1.26.2/docker-compose-$( uname -s) -$( uname -m) " -o /usr/local/bin/docker-compose
251+ os_name=$( uname -s)
252+ arch=$( uname -m)
253+ sudo curl -L " https://github.com/docker/compose/releases/download/1.26.2/docker-compose-${os_name} -${arch} " -o /usr/local/bin/docker-compose
250254 sudo chmod +x /usr/local/bin/docker-compose
251255 echo
252256}
@@ -482,7 +486,10 @@ elif [[ "${os_type}" = "Darwin" ]]; then
482486 echo
483487 else
484488 echo -e " \033[30m===>\033[0m \033[32mInstalling Homebrew... \033[0m"
485- /bin/bash -c " $( curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh) "
489+ brew_installer=$( mktemp -d)
490+ curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh > " ${brew_installer} " /install.sh
491+ chmod +x " ${brew_installer} " /install.sh
492+ " ${brew_installer} /install.sh"
486493 echo
487494 fi
488495
0 commit comments