Skip to content

Commit

Permalink
Fix README, add HELP function
Browse files Browse the repository at this point in the history
  • Loading branch information
intrudir committed Mar 20, 2023
1 parent b3e7ba4 commit ce8f3d9
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 25 deletions.
41 changes: 26 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,39 @@
# vm-setup.sh
My handy bash script to quickly set up debian linux VM's how I like em :)

### Install
Run the following:
```bash
git clone https://github.com/intrudir/vm-setup.sh.git
cd vm-setup.sh
chmod +x vm-setup.sh
```

## Usage
Havent tested on Mac yet btw :)
Haven't tested on Mac yet :)

No need to `git clone`. From your linux machine simply...
For every script, depending on if you want the full VM install or just minimal CTF things, run with `-t full` or `-t ctf` like so:

Run the following and follow the prompts.
### Everything in one shot
```bash
wget https://raw.githubusercontent.com/intrudir/vm-setup.sh/main/1.vm-setup.sh

chmod +x 1.vm-setup.sh

./1.vm-setup.sh
./vm-setup.sh -t ctf
```

<br>

Install my favorite tools:

### Install just the configs
```bash
wget https://raw.githubusercontent.com/intrudir/vm-setup.sh/main/2.install-tools.sh
chmod +x install-configs.sh
./install-configs.sh -t ctf
```

chmod +x 2.install-tools.sh
### Install just the tools
Requires golang to be installed already
```bash
chmod +x install-tools.sh
./install-tools.sh -t ctf
```

./2.install-tools.sh
### Just install latest Golang for your architecture
```bash
chmod +x install-golang.sh
./install-golang.sh
```
41 changes: 33 additions & 8 deletions install-configs.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,23 @@
#!/bin/bash

# Set Script Name variable
SCRIPT=`basename ${BASH_SOURCE[0]}`

# Set fonts for Help.
NORM=`tput sgr0`
BOLD=`tput bold`
REV=`tput smso`

# Help function
function HELP {
echo -e \\n"Help documentation for ${BOLD}${SCRIPT}.${NORM}"\\n
echo -e "${REV}Basic usage:${NORM} ${BOLD}$SCRIPT -t [full, ctf]${NORM}"\\n
echo "${REV}-t${NORM} --Choose between 'full' or 'ctf' VM installs."
echo -e "${REV}-h${NORM} --Displays this help message and exits."\\n
echo -e "Example: ${BOLD}$SCRIPT -t ctf"\\n
exit 1
}

function check_if_success () {
if [ $? -eq 0 ]; then
echo "OK"
Expand All @@ -8,6 +27,12 @@ function check_if_success () {
fi
}

# Check the number of arguments. If none are passed, print help and exit.
NUMARGS=$#
if [ $NUMARGS -eq 0 ]; then
HELP
fi

while getopts 'h:t:' flag; do
case "$flag" in
h) echo "usage";;
Expand All @@ -30,27 +55,27 @@ fi
echo "VM type: $type";

if [[ $type == 'full' ]]; then
echo "\nFull vim config"
echo -e \\n"Installing full vim config"
# vim_rc=$(curl https://raw.githubusercontent.com/intrudir/vm-setup.sh/main/dotfiles/full-vimrc)
vim_rc=$(cat ./dotfiles/full-vimrc)
echo "$vim_rc" > ~/.vimrc

echo "\nFull shell aliases"
echo -e \\n"Installing full shell aliases"
# zsh_rc=$(curl https://raw.githubusercontent.com/intrudir/vm-setup.sh/main/dotfiles/full-aliases)
zsh_rc=$(cat ./dotfiles/full-aliases)
echo "$zsh_rc" >> ~/.zshrc
echo "$zsh_rc" >> ~/.bash_aliases

echo "\nFull tmux.conf"
echo -e \\n"Installing full tmux.conf"
# tmux_conf=$(curl https://raw.githubusercontent.com/intrudir/vm-setup.sh/main/dotfiles/full-tmux.conf)
tmux_conf=$(cat ./dotfiles/full-tmux.conf)
echo "$tmux_conf" > ~/.tmux.conf

echo "\nInstall VIM plug"
echo -e \\n"Installing VIM plug"
curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
check_if_success

echo "\nInstall tmux themes"
echo -e \\n"Installing tmux themes"
sudo mkdir /opt/tmux && cd /opt/tmux
check_if_success
sudo git clone https://github.com/wfxr/tmux-power.git
Expand All @@ -59,18 +84,18 @@ fi


if [[ $type == 'ctf' ]]; then
echo "\nCTF vim config"
echo -e \\n"Installing CTF vim config"
# vim_rc=$(curl https://raw.githubusercontent.com/intrudir/vm-setup.sh/main/dotfiles/ctf-vimrc)
vim_rc=$(cat ./dotfiles/ctf-vimrc)
echo "$vim_rc" > ~/.vimrc

echo "\nCTF shell aliases"
echo -e \\n"Installing CTF shell aliases"
# zsh_rc=$(curl https://raw.githubusercontent.com/intrudir/vm-setup.sh/main/dotfiles/ctf-aliases)
zsh_rc=$(cat ./dotfiles/ctf-aliases)
echo "$zsh_rc" >> ~/.zshrc
echo "$zsh_rc" >> ~/.bash_aliases

echo "\nCTF tmux.conf"
echo -e \\n"Installing CTF tmux.conf"
# tmux_conf=$(curl https://raw.githubusercontent.com/intrudir/vm-setup.sh/main/dotfiles/ctf-tmux.conf)
tmux_conf=$(cat ./dotfiles/ctf-tmux.conf)
echo "$tmux_conf" > ~/.tmux.conf
Expand Down
25 changes: 25 additions & 0 deletions install-tools.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,23 @@
#!/bin/bash

# Set Script Name variable
SCRIPT=`basename ${BASH_SOURCE[0]}`

# Set fonts for Help.
NORM=`tput sgr0`
BOLD=`tput bold`
REV=`tput smso`

# Help function
function HELP {
echo -e \\n"Help documentation for ${BOLD}${SCRIPT}.${NORM}"\\n
echo -e "${REV}Basic usage:${NORM} ${BOLD}$SCRIPT -t [full, ctf]${NORM}"\\n
echo "${REV}-t${NORM} --Choose between 'full' or 'ctf' VM installs."
echo -e "${REV}-h${NORM} --Displays this help message and exits."\\n
echo -e "Example: ${BOLD}$SCRIPT -t ctf"\\n
exit 1
}

function check_if_success () {
if [ $? -eq 0 ]; then
echo "OK"
Expand All @@ -8,6 +27,12 @@ function check_if_success () {
fi
}

# Check the number of arguments. If none are passed, print help and exit.
NUMARGS=$#
if [ $NUMARGS -eq 0 ]; then
HELP
fi

while getopts 'h:t:' flag; do
case "$flag" in
h) echo "usage";;
Expand Down
29 changes: 27 additions & 2 deletions vm-setup.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
#!/bin/bash

# Set Script Name variable
SCRIPT=`basename ${BASH_SOURCE[0]}`

# Set fonts for Help.
NORM=`tput sgr0`
BOLD=`tput bold`
REV=`tput smso`

# Help function
function HELP {
echo -e \\n"Help documentation for ${BOLD}${SCRIPT}.${NORM}"\\n
echo -e "${REV}Basic usage:${NORM} ${BOLD}$SCRIPT -t [full, ctf]${NORM}"\\n
echo "${REV}-t${NORM} --Choose between 'full' or 'ctf' VM installs."
echo -e "${REV}-h${NORM} --Displays this help message and exits."\\n
echo -e "Example: ${BOLD}$SCRIPT -t ctf"\\n
exit 1
}

function check_if_success () {
if [ $? -eq 0 ]; then
echo "OK"
Expand All @@ -9,6 +27,12 @@ function check_if_success () {
fi
}

# Check the number of arguments. If none are passed, print help and exit.
NUMARGS=$#
if [ $NUMARGS -eq 0 ]; then
HELP
fi

while getopts 'h:t:' flag; do
case "$flag" in
h) echo "usage";;
Expand All @@ -18,13 +42,14 @@ while getopts 'h:t:' flag; do
done

if [ -v "$type" ]; then
HELP
echo "The -t flag is required. Needs to be one of the following: ['full', 'ctf']"
exit 1
fi


if [[ ! $type == 'full' ]] && [[ ! $type == 'ctf' ]]; then
echo "the -t flag needs to be either 'full' or 'ctf'."
HELP
echo "The -t flag needs to be either 'full' or 'ctf'."
exit 1
fi

Expand Down

0 comments on commit ce8f3d9

Please sign in to comment.