Add install.sh

This commit is contained in:
Ceda EI 2019-05-15 13:04:36 +05:30
parent 17ded98998
commit 5c01d9fd1e
1 changed files with 36 additions and 0 deletions

36
install.sh Normal file
View File

@ -0,0 +1,36 @@
#!/usr/bin/env bash
cd
if hash git 2> /dev/null; then
[[ -a Server-Dotfiles ]] && mv Server-Dotfiles Server-Dotfiles-$(date +%s)
git clone https://git.webionite.com/ceda_ei/Server-Dotfiles
./Server-Dotfiles/deploy.sh
else
echo "git not found. Trying with curl/wget and tar/unzip" >&2
if ! hash tar 2> /dev/null; then
if ! hash unzip; then
echo "tar or unzip not found" >&2
exit 1
else
file_format=".zip"
fi
else
file_format=".tar.gz"
fi
[[ -a Server-Dotfiles$file_format ]] && mv Server-Dotfiles$file_format Server-Dotfiles-$(date +%s)$file_format
[[ -a server-dotfiles ]] && mv server-dotfiles server-dotfiles-$(date +%s)
if hash curl 2> /dev/null; then
curl -o Server-Dotfiles$file_format https://git.webionite.com/ceda_ei/Server-Dotfiles/archive/master$file_format
elif hash wget 2> /dev/null; then
wget -O Server-Dotfiles$file_format https://git.webionite.com/ceda_ei/Server-Dotfiles/archive/master$file_format
else
echo "curl or wget not found" >&2
fi
if [[ $file_format == ".zip" ]]; then
unzip Server-Dotfiles$file_format
elif [[ $file_format == ".tar.gz" ]]; then
tar xzf Server-Dotfiles$file_format
fi
./server-dotfiles/deploy.sh
fi