-
Notifications
You must be signed in to change notification settings - Fork 12
/
pve_nas_installer.sh
110 lines (90 loc) · 3.89 KB
/
pve_nas_installer.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/usr/bin/env bash
# ----------------------------------------------------------------------------------
# Filename: pve_nas_installer.sh
# Description: Installer script for PVE Homelab
# ----------------------------------------------------------------------------------
#---- Bash command to run script ---------------------------------------------------
#---- Source Github
# bash -c "$(wget -qLO - https://raw.githubusercontent.com/ahuacate/pve-nas/main/pve_nas_installer.sh)"
#---- Source local Git
# /mnt/pve/nas-01-git/ahuacate/pve-nas/pve_nas_installer.sh
#---- Installer Vars ---------------------------------------------------------------
# Git server
GIT_SERVER='https://github.com'
# Git user
GIT_USER='ahuacate'
# Git repository
GIT_REPO='pve-nas'
# Git branch
GIT_BRANCH='main'
# Git common
GIT_COMMON='0'
# Edit this list to set installer product(s).
# vm_LIST=( "name:build:vm_type:desc" )
# name ---> name of the main application
# build_model ---> build model/version of the name (i.e omv build version for a nas)
# vm_type ---> 'vm' or 'ct'
# desc ---> description of the main application name
# Fields must match GIT_APP_SCRIPT dir and filename:
# i.e .../<build_type>/${GIT_REPO}_<vm_type>_<app_name>_installer.sh '(i.e .../ubuntu/pve_nas_ct_nas_installer.sh')
vm_LIST=( "nas:ubuntu:ct:Ubuntu CT based NAS" \
"nas:debian:ct:Debian Cockpit CT based NAS" \
"nas:omv:vm:OMV based NAS (Requires PCIe HBA or disk passthrough)")
#-----------------------------------------------------------------------------------
# NO NOT EDIT HERE DOWN
#---- Dependencies -----------------------------------------------------------------
#---- Check for Internet connectivity
# List of well-known websites to test connectivity (in case one is blocked)
websites=( "google.com 443" "github.com 443" "cloudflare.com 443" "apple.com 443" "amazon.com 443" )
# Loop through each website in the list
for website in "${websites[@]}"
do
# Test internet connectivity
nc -zw1 $website > /dev/null 2>&1
# Check the exit status of the ping command
if [ $? = 0 ]
then
# Flag to track if internet connection is up
connection_up=0
break
else
# Flag to track if internet connection is down
connection_up=1
fi
done
# On connection fail
if [ "$connection_up" = 1 ]
then
echo "Checking for internet connectivity..."
echo -e "Internet connectivity status: \033[0;31mDown\033[0m\n\nCannot proceed without a internet connection.\nFix your PVE hosts internet connection and try again..."
echo
exit 0
fi
#---- Static Variables -------------------------------------------------------------
#---- Set Package Installer Temp Dir
# Set 'rep_temp' dir
REPO_TEMP='/tmp'
# Change to 'repo temp' dir
cd $REPO_TEMP
#---- Local Repo path (check if local)
# For local SRC a 'developer_settings.git' file must exist in repo dir
REPO_PATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P | sed "s/${GIT_USER}.*/$GIT_USER/" )"
#---- Other Variables --------------------------------------------------------------
#---- Other Files ------------------------------------------------------------------
#---- Package loader
# Check for local source
if [ -f "$REPO_PATH/common/bash/src/pve_repo_loader.sh" ] && [ "$(sed -n 's/^dev_git_mount=//p' $REPO_PATH/developer_settings.git 2> /dev/null)" = 0 ]
then
# Download Local loader (developer)
source $REPO_PATH/common/bash/src/pve_repo_loader.sh
else
# Download Github loader
wget -qL - https://raw.githubusercontent.com/$GIT_USER/common/main/bash/src/pve_repo_loader.sh -O $REPO_TEMP/pve_repo_loader.sh
chmod +x $REPO_TEMP/pve_repo_loader.sh
source $REPO_TEMP/pve_repo_loader.sh
fi
#---- Body -------------------------------------------------------------------------
#---- Run Installer
# Run repo installer (repo product selector)
source $REPO_PATH/$GIT_REPO/common/bash/src/pve_repo_installer_main.sh
#-----------------------------------------------------------------------------------