├── Configuration Guides.md ├── Jenkins Build.md ├── Jenkins and Git Config ├── Jenkins and Mocha Security Testing ├── README.md ├── cheat ├── development-pipeline.pdf ├── pics ├── build trigger and env.png ├── deploy.png ├── destroy containers.png ├── git settings.png ├── git ssh keys.png ├── nightly build.png ├── push to git.png └── source code management.png └── simon network.pdf /Configuration Guides.md: -------------------------------------------------------------------------------- 1 | # Configuration Guides 2 | 3 | * [How to build projects with Jenkins](https://github.com/so87/Home-Lab/blob/master/Jenkins%20Build.md) 4 | * [Configure Jenkins/Git](https://github.com/so87/Home-Lab/blob/master/Jenkins%20and%20Git%20Config) 5 | * [Jenkins/Mocha Security Testing](https://github.com/so87/Home-Lab/blob/master/Jenkins%20and%20Mocha%20Security%20Testing) 6 | -------------------------------------------------------------------------------- /Jenkins Build.md: -------------------------------------------------------------------------------- 1 | # How to build projects with Jenkins 2 | Need to download plugins for sonarqube, docker, ssh, badges, and github 3 | 4 | ## Make ssh key for jenkins machine 5 | 6 | Navigate to the below area on github and create an SSH key for your jenkins machine. This is 7 | so jenkins can push dev code to production. 8 |

9 | 10 |

11 | 12 | ## Setup jenkins bulid to poll github for events, scan with sonarqube, and deploy 13 | 14 | ### Pull code from repository 15 |

16 | 17 |

18 | 19 | ### Trigger the build after a commit has been pushed to github 20 |

21 | 22 |

23 | 24 | ### Nightly jenkins event 25 |

26 | 27 |

28 | 29 | ### Deploy containers 30 |

31 | 32 |

33 | 34 | ### Destroy containers 35 |

36 | 37 |

38 | 39 | ### Push the results back to production 40 |

41 | 42 |

43 | 44 |

45 | 46 |

47 | -------------------------------------------------------------------------------- /Jenkins and Git Config: -------------------------------------------------------------------------------- 1 | # Jenkins/Git Integration 2 | https://docs.bitnami.com/aws/how-to/create-ci-pipeline/ 3 | turn off "allow requests to the local network from hooks and services" in github if you are pulling from local github 4 | 5 | -------------------------------------------------------------------------------- /Jenkins and Mocha Security Testing: -------------------------------------------------------------------------------- 1 | # Jenkins/Mocha Security Testing 2 | 1. Downloading practice 3 | 4 | 5 | 2. Writing a test 6 | 7 | 8 | 3. Adding to build 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 |

4 | 5 | # Home Lab 6 | This repository holds the documentation for my home lab I've built up and guides for others wanting 7 | to build their own home network. Building your own home network is the best way to learn and can be 8 | much cheaper than you think. 9 | 10 | 11 | ### Network Diagram 12 | This is my current network configuration. I used Visio to create the diagram. 13 | [NETWORK DIAGRAM](https://github.com/so87/Home-Lab/blob/master/simon%20network.pdf). 14 | 15 | ### Software Development Excellence 16 | The best thing about having all of this equipment is being able to deliver high quality software. Every piece of software I write goes through my own Jenkins pipeline. This pipeline runs static code analysis tests to reduce the amount of bugs, vulnerabilities, and technical debt. I also write my own mocha security tests with Mocha to ensure my architecture is secure. Once all of these tests pass, the code gets merged into production, and automatically deployed. See the diagram. 17 | [CODING PROCESS](https://github.com/so87/Home-Lab/blob/master/development-pipeline.pdf). 18 | #### Deployment Process 19 |

20 | 21 |

65 | Reddit also has a great write-up for getting started
66 | [Reddit Guide](https://www.reddit.com/r/homelab/wiki/buyingguide) 67 | 68 | Here is a great guide for making your own home NAS
69 | [DIY NAS](https://blog.briancmoses.com/2017/03/diy-nas-2017-edition.html) 70 | 71 | # Community 72 | This is a really great community for seeing what others do. Great resource for building your 73 | own homelab. Becareful browsing this sub-reddit too much... it may make you buy expensive equipment.
74 | [Reddit Home Lab](https://www.reddit.com/r/homelab/) 75 | -------------------------------------------------------------------------------- /cheat: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Author: Alexander Epstein https://github.com/alexanderepstein 3 | 4 | currentVersion="1.22.0" 5 | configuredClient="" 6 | ## rest of these variables are search flags 7 | search="0" 8 | insensitive="" 9 | recursive="" 10 | boundry="" 11 | 12 | ## This function determines which http get tool the system has installed and returns an error if there isnt one 13 | getConfiguredClient() 14 | { 15 | if command -v curl &>/dev/null; then 16 | configuredClient="curl" 17 | elif command -v wget &>/dev/null; then 18 | configuredClient="wget" 19 | elif command -v http &>/dev/null; then 20 | configuredClient="httpie" 21 | elif command -v fetch &>/dev/null; then 22 | configuredClient="fetch" 23 | else 24 | echo "Error: This tool reqires either curl, wget, httpie or fetch to be installed." >&2 25 | return 1 26 | fi 27 | } 28 | 29 | ## Allows to call the users configured client without if statements everywhere 30 | httpGet() 31 | { 32 | case "$configuredClient" in 33 | curl) curl -A curl -s "$@" ;; 34 | wget) wget -qO- "$@" ;; 35 | httpie) http -b GET "$@" ;; 36 | fetch) fetch -q "$@" ;; 37 | esac 38 | } 39 | 40 | 41 | checkInternet() 42 | { 43 | httpGet github.com > /dev/null 2>&1 || { echo "Error: no active internet connection" >&2; return 1; } # query github with a get request 44 | } 45 | 46 | update() 47 | { 48 | # Author: Alexander Epstein https://github.com/alexanderepstein 49 | # Update utility version 2.2.0 50 | # To test the tool enter in the defualt values that are in the examples for each variable 51 | repositoryName="Bash-Snippets" #Name of repostiory to be updated ex. Sandman-Lite 52 | githubUserName="alexanderepstein" #username that hosts the repostiory ex. alexanderepstein 53 | nameOfInstallFile="install.sh" # change this if the installer file has a different name be sure to include file extension if there is one 54 | latestVersion=$(httpGet https://api.github.com/repos/$githubUserName/$repositoryName/tags | grep -Eo '"name":.*?[^\\]",'| head -1 | grep -Eo "[0-9.]+" ) #always grabs the tag without the v option 55 | 56 | if [[ $currentVersion == "" || $repositoryName == "" || $githubUserName == "" || $nameOfInstallFile == "" ]]; then 57 | echo "Error: update utility has not been configured correctly." >&2 58 | exit 1 59 | elif [[ $latestVersion == "" ]]; then 60 | echo "Error: no active internet connection" >&2 61 | exit 1 62 | else 63 | if [[ "$latestVersion" != "$currentVersion" ]]; then 64 | echo "Version $latestVersion available" 65 | echo -n "Do you wish to update $repositoryName [Y/n]: " 66 | read -r answer 67 | if [[ "$answer" == [Yy] ]]; then 68 | cd ~ || { echo 'Update Failed'; exit 1; } 69 | if [[ -d ~/$repositoryName ]]; then rm -r -f $repositoryName || { echo "Permissions Error: try running the update as sudo"; exit 1; } ; fi 70 | echo -n "Downloading latest version of: $repositoryName." 71 | git clone -q "https://github.com/$githubUserName/$repositoryName" && touch .BSnippetsHiddenFile || { echo "Failure!"; exit 1; } & 72 | while [ ! -f .BSnippetsHiddenFile ]; do { echo -n "."; sleep 2; };done 73 | rm -f .BSnippetsHiddenFile 74 | echo "Success!" 75 | cd $repositoryName || { echo 'Update Failed'; exit 1; } 76 | git checkout "v$latestVersion" 2> /dev/null || git checkout "$latestVersion" 2> /dev/null || echo "Couldn't git checkout to stable release, updating to latest commit." 77 | chmod a+x install.sh #this might be necessary in your case but wasnt in mine. 78 | ./$nameOfInstallFile "update" || exit 1 79 | cd .. 80 | rm -r -f $repositoryName || { echo "Permissions Error: update succesfull but cannot delete temp files located at ~/$repositoryName delete this directory with sudo"; exit 1; } 81 | else 82 | exit 1 83 | fi 84 | else 85 | echo "$repositoryName is already the latest version" 86 | fi 87 | fi 88 | } 89 | 90 | usage() 91 | { 92 | cat <&2 167 | exit 1 168 | ;; 169 | h) usage 170 | exit 0 171 | ;; 172 | v) echo "Version $currentVersion" 173 | exit 0 174 | ;; 175 | u) 176 | checkInternet || exit 1 177 | update 178 | exit 0 179 | ;; 180 | i) insensitive="i" 181 | search="1" 182 | ;; 183 | b) boundry="b" 184 | search="1" 185 | ;; 186 | r) recursive="r" 187 | search="1" 188 | ;; 189 | s) search="1" 190 | ;; 191 | :) echo "Option -$OPTARG requires an argument." >&2 192 | exit 1 193 | ;; 194 | esac 195 | done 196 | 197 | ### This functions sets arg 1 and arg 2 to be unqique items after the options 198 | for arg; do 199 | if [[ $arg != "-r" && $arg != "-s" && $arg != "-b" && $arg != "-i" ]]; then 200 | if [ -z ${arg1+x} ]; then 201 | arg1=$arg 202 | fi 203 | if [ ! -z ${arg1+x} ]; then 204 | arg2=$arg 205 | fi 206 | fi 207 | done 208 | 209 | ## check for special pages before moving on 210 | checkSpecialPage $arg1 1 211 | checkSpecialPage $arg2 2 212 | 213 | if [[ $# == 0 ]]; then 214 | usage 215 | exit 0 216 | elif [[ $1 == "update" ]]; then 217 | checkInternet || exit 1 218 | update 219 | exit 0 220 | elif [[ $1 == "help" || $1 == ":help" ]]; then ## shows the help and prevents the user from seeing cheat.sh/:help 221 | usage 222 | exit 0 223 | else 224 | checkInternet || exit 1 225 | if [[ $arg1 != $arg2 ]]; then ## if they equal each other that means there was no arg 2 supplied 226 | getCheatSheet $arg1 $arg2 227 | exit 0 228 | else 229 | getCheatSheet $arg1 230 | exit 0 231 | fi 232 | exit 0 233 | fi 234 | -------------------------------------------------------------------------------- /development-pipeline.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/so87/Home-Lab/1f7734efefa3c571b0234a7764d1125c719bbae4/development-pipeline.pdf -------------------------------------------------------------------------------- /pics/build trigger and env.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/so87/Home-Lab/1f7734efefa3c571b0234a7764d1125c719bbae4/pics/build trigger and env.png -------------------------------------------------------------------------------- /pics/deploy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/so87/Home-Lab/1f7734efefa3c571b0234a7764d1125c719bbae4/pics/deploy.png -------------------------------------------------------------------------------- /pics/destroy containers.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/so87/Home-Lab/1f7734efefa3c571b0234a7764d1125c719bbae4/pics/destroy containers.png -------------------------------------------------------------------------------- /pics/git settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/so87/Home-Lab/1f7734efefa3c571b0234a7764d1125c719bbae4/pics/git settings.png -------------------------------------------------------------------------------- /pics/git ssh keys.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/so87/Home-Lab/1f7734efefa3c571b0234a7764d1125c719bbae4/pics/git ssh keys.png -------------------------------------------------------------------------------- /pics/nightly build.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/so87/Home-Lab/1f7734efefa3c571b0234a7764d1125c719bbae4/pics/nightly build.png -------------------------------------------------------------------------------- /pics/push to git.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/so87/Home-Lab/1f7734efefa3c571b0234a7764d1125c719bbae4/pics/push to git.png -------------------------------------------------------------------------------- /pics/source code management.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/so87/Home-Lab/1f7734efefa3c571b0234a7764d1125c719bbae4/pics/source code management.png -------------------------------------------------------------------------------- /simon network.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/so87/Home-Lab/1f7734efefa3c571b0234a7764d1125c719bbae4/simon network.pdf --------------------------------------------------------------------------------