mirror of
https://github.com/RyanGreenup/cadmus.git
synced 2025-01-17 20:58:38 +01:00
Simplified Install Script
This commit is contained in:
parent
e003b62746
commit
d188e963c9
85
install.sh
85
install.sh
@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
INSTALL_DIR="$HOME/.cadmus"
|
||||
|
||||
main () {
|
||||
me=`basename "$0"`
|
||||
@ -6,16 +7,22 @@ main () {
|
||||
HelpStatement $1
|
||||
UninstallQ $1
|
||||
printThis
|
||||
check_for_dependencies
|
||||
download_the_repo
|
||||
Install_tools "S"
|
||||
Install_bin
|
||||
check_path
|
||||
check_for_dependencies
|
||||
}
|
||||
|
||||
check_path () {
|
||||
echo "$PATH" | grep -q '.local/bin' || echo "bin-dir is not in path, you'll need to add it to the path"
|
||||
}
|
||||
|
||||
function UninstallQ() {
|
||||
|
||||
if [ "$1" == "-rm" ] || [ "$1" == "--rm" ]; then
|
||||
echo "Removing with Stow"
|
||||
Install_tools "D"
|
||||
echo "Removing..."
|
||||
rm "$HOME/.local/bin/cadmus"
|
||||
rm "${INSTALL_DIR}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
@ -62,27 +69,34 @@ printThis () {
|
||||
|
||||
safePrint () {
|
||||
if hash highlight 2>/dev/null; then
|
||||
highlight "$@"
|
||||
highlight "${1}" --syntax=bash --stdout
|
||||
else
|
||||
cat "$@"
|
||||
cat "${1}"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
check_for_dependencies () {
|
||||
|
||||
echo "Press Any Key to Check for dependencies, press the c Key to Skip this"
|
||||
read -d '' -s -n1 CheckDepQ
|
||||
if [ "$CheckDepQ" == "c" ]; then
|
||||
return
|
||||
fi
|
||||
echo "Missing dependencies will now be printed to STDERR, missing packages to STDOUT"
|
||||
|
||||
## echo "Press Any Key to Check for dependencies, press the c Key to Skip this"
|
||||
## read -d '' -s -n1 CheckDepQ
|
||||
## if [ "$CheckDepQ" == "c" ]; then
|
||||
## return
|
||||
## fi
|
||||
##
|
||||
depLog="$(mktemp)"
|
||||
|
||||
for i in ${StringArray[@]}; do
|
||||
command -v "$i" >/dev/null 2>&1 || { echo >&2 "I require $i but it's not installed. Aborting."; exit 1; }
|
||||
command -v "$i" >/dev/null 2>&1 || { echo >&2 "I require $i but it's not installed. Aborting."; echo $i >> "${depLog}"; }
|
||||
done
|
||||
|
||||
echo "All Dependencies Satisfied"
|
||||
|
||||
if [[ $(cat "${depLog}") == "" ]]; then
|
||||
echo "All Dependencies Satisfied"
|
||||
else
|
||||
cat "${depLog}"
|
||||
fi
|
||||
}
|
||||
|
||||
download_the_repo () {
|
||||
@ -93,40 +107,37 @@ download_the_repo () {
|
||||
return
|
||||
fi
|
||||
|
||||
mkdir -p $HOME/DotFiles/
|
||||
cd $HOME/DotFiles
|
||||
|
||||
|
||||
if [[ -d ".git" ]]; then
|
||||
echo "Detected a Git Repo, Press y to add a submodule or any key to exit"
|
||||
|
||||
read -d '' -s -n1 CheckDepQ
|
||||
if [ "$CheckDepQ" != "y" ]; then
|
||||
echo "You pressed any key"
|
||||
fi
|
||||
|
||||
git submodule add https://github.com/RyanGreenup/cadmus && echo "Submodule succesfully added"
|
||||
|
||||
if [[ -d "${INSTALL_DIR}/.git" ]]; then
|
||||
echo "Detected a cadmus install"
|
||||
ask_to_remove
|
||||
elif [[ -f ".git" ]]; then
|
||||
echo "You have a file called .git In there, delete that first.";
|
||||
echo "You have a file called .git In "${INSTALL_DIR}", which was unexpected"
|
||||
ask_to_remove
|
||||
else
|
||||
git clone https://github.com/RyanGreenup/cadmus
|
||||
git clone https://github.com/RyanGreenup/cadmus "~/.cadmus"
|
||||
fi
|
||||
|
||||
echo "Repository is downloaded"
|
||||
|
||||
}
|
||||
|
||||
Install_tools () {
|
||||
ask_to_remove () {
|
||||
echo "press y to remove "${INSTALL_DIR}""
|
||||
|
||||
DIR=$(dirname "$0")
|
||||
cd "$DIR" && cd ../
|
||||
echo "Stow package $DIR, target $HOME"
|
||||
stow -t $HOME -$1 "$(basename "$DIR")"
|
||||
read -d '' -s -n1 CheckDepQ
|
||||
if [ "$CheckDepQ" != "y" ]; then
|
||||
rm -rf "${INSTALL_DIR}"
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
Install_bin() {
|
||||
ln -s "$HOME/.cadmus/bin/cadmus" "$HOME/.local/bin/"
|
||||
}
|
||||
|
||||
# Declare an array of string with type
|
||||
declare -a StringArray=("R"
|
||||
declare -a StringArray=(
|
||||
"highlight"
|
||||
"node"
|
||||
"nvim"
|
||||
@ -140,6 +151,8 @@ declare -a StringArray=("R"
|
||||
"tmsu"
|
||||
"ranger"
|
||||
"mdcat"
|
||||
"jq"
|
||||
"shift"
|
||||
"xclip"
|
||||
"sd"
|
||||
"fd"
|
||||
|
Loading…
x
Reference in New Issue
Block a user