-
Notifications
You must be signed in to change notification settings - Fork 16
/
pve_medialab_toolbox.sh
98 lines (79 loc) · 3.29 KB
/
pve_medialab_toolbox.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
#!/usr/bin/env bash
# ----------------------------------------------------------------------------------
# Filename: pve_medialab_toolbox.sh
# Description: Toolbox script for VM/LXC/CT and Apps
# ----------------------------------------------------------------------------------
#---- Bash command to run script ---------------------------------------------------
#---- Source Github
# bash -c "$(wget -qLO - https://raw.githubusercontent.com/ahuacate/pve-medialab/main/pve_medialab_toolbox.sh)"
#---- Source local Git
# /mnt/pve/nas-01-git/ahuacate/pve-medialab/pve_medialab_toolbox.sh
#---- Installer Vars ---------------------------------------------------------------
# Git server
GIT_SERVER='https://github.com'
# Git user
GIT_USER='ahuacate'
# Git repository
GIT_REPO='pve-medialab'
# Git branch
GIT_BRANCH='main'
# Git common
GIT_COMMON='0'
#-----------------------------------------------------------------------------------
# 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_toolbox_main.sh
#-----------------------------------------------------------------------------------