Mind_Reader/setup-development/linux/install-linux.sh

65 lines
1.3 KiB
Bash
Raw Normal View History

#!/bin/bash
#* linux-install.sh: First-run setup script
#* Ensures git is installed, clones the repo, and then runs
export PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
2022-04-28 22:38:47 +00:00
ELEVATE='';if (( $UID !=0 )); then ELEVATE='sudo';fi
help () {
2022-04-28 23:10:31 +00:00
echo "Usage: $0 [-d] [-g path/to/git/directory]"
exit 0
}
2022-04-28 23:10:31 +00:00
gitdir=~/git
# Get option flags:
dry=false
while getopts ghd arg; do
case $arg in
2022-04-28 22:41:19 +00:00
g) gitdir="$OPTARG";;
h) help;;
d) dry=true;;
esac
done
function dryrun {
if $dry; then
echo "> $* [dry]";
else
echo "> $*"
$@
2022-04-28 22:43:21 +00:00
fi
}
2022-04-28 23:10:31 +00:00
setupdir="Mind_Reader/setup-development/linux"
2022-04-28 22:41:19 +00:00
repouri="https://github.com/We-Dont-Byte/Mind_Reader.git"
# Install git
if which git; then
echo "Git already installed."
elif which pacman; then
# using pacman
dryrun $ELEVATE pacman -Sy git
elif which apt; then
# using apt
dryrun $ELEVATE apt-get update && \
dryrun $ELEVATE apt-get install git -y
fi #? TODO: other package managers?
2022-05-05 21:31:48 +00:00
printf "\nCloning repository into $gitdir\n"
2022-04-28 22:41:19 +00:00
dryrun mkdir "$gitdir"
2022-04-28 23:10:31 +00:00
cd $gitdir && dryrun git clone "$repouri"
# TODO: remove this when merging!
cd Mind_Reader
2022-04-28 23:10:31 +00:00
dryrun git checkout johnBreaux
# TODO: remove this when merging!
2022-04-28 22:41:19 +00:00
cd "$gitdir/$setupdir"
2022-04-28 23:10:31 +00:00
bash ./upgrade-linux.sh $@
echo "Opening VS Code..."
cd $gitdir/Mind_Reader
code .