61 lines
1.2 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 17:38:47 -05:00
ELEVATE='';if (( $UID !=0 )); then ELEVATE='sudo';fi
help () {
2022-04-28 18:10:31 -05:00
echo "Usage: $0 [-d] [-g path/to/git/directory]"
exit 0
}
2022-04-28 18:10:31 -05:00
gitdir=~/git
# Get option flags:
dry=false
while getopts ghd arg; do
case $arg in
2022-04-28 17:41:19 -05:00
g) gitdir="$OPTARG";;
h) help;;
d) dry=true;;
esac
done
function dryrun {
if $dry; then
echo "> $* [dry]";
else
echo "> $*"
$@
2022-04-28 17:43:21 -05:00
fi
}
2022-04-28 18:10:31 -05:00
setupdir="Mind_Reader/setup-development/linux"
2022-04-28 17:41:19 -05: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 16:31:48 -05:00
printf "\nCloning repository into $gitdir\n"
2022-04-28 17:41:19 -05:00
dryrun mkdir "$gitdir"
2022-04-28 18:10:31 -05:00
cd $gitdir && dryrun git clone "$repouri"
2022-04-28 17:41:19 -05:00
cd "$gitdir/$setupdir"
2022-04-28 18:10:31 -05:00
bash ./upgrade-linux.sh $@
echo "Opening VS Code..."
cd $gitdir/Mind_Reader
2022-05-09 20:07:34 -05:00
code .