1+ #! /usr/bin/env bash
2+
3+ # Copyright (c) 2021-2024 tteck
4+ # Author: MickLesk
5+ # License: MIT
6+ # https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
7+
8+ function header_info {
9+ clear
10+ cat << "EOF "
11+ __ __ __ __ ____
12+ / / / /___ ____/ /___ _/ /____ / __ \___ ____ ____
13+ / / / / __ \/ __ / __ `/ __/ _ \ / /_/ / _ \/ __ \/ __ \
14+ / /_/ / /_/ / /_/ / /_/ / /_/ __/ / _, _/ __/ /_/ / /_/ /
15+ \____/ .___/\__,_/\__,_/\__/\___/ /_/ |_|\___/ .___/\____/
16+ /_/ /_/
17+ EOF
18+ }
19+
20+ set -eEuo pipefail
21+ BL=$( echo " \033[36m" )
22+ RD=$( echo " \033[01;31m" )
23+ GN=$( echo " \033[1;92m" )
24+ CL=$( echo " \033[m" )
25+
26+ header_info
27+ echo " Loading..."
28+ NODE=$( hostname)
29+
30+ function update_container() {
31+ container=$1
32+ os=$( pct config " $container " | awk ' /^ostype/ {print $2}' )
33+
34+ if [[ " $os " == " ubuntu" || " $os " == " debian" ]]; then
35+ echo -e " ${BL} [Info]${GN} Checking /usr/bin/update in ${BL} $container ${CL} (OS: ${GN} $os ${CL} )"
36+
37+ if pct exec " $container " -- [ -e /usr/bin/update ]; then
38+ if pct exec " $container " -- grep -q " community-scripts/ProxmoxVE" /usr/bin/update; then
39+ echo -e " ${RD} [No Change]${CL} /usr/bin/update is already up to date in ${BL} $container ${CL} .\n"
40+ elif pct exec " $container " -- grep -q " tteck" /usr/bin/update; then
41+ echo -e " ${RD} [Warning]${CL} /usr/bin/update in ${BL} $container ${CL} contains a different entry (${RD} tteck${CL} ). No changes made.\n"
42+ else
43+ pct exec " $container " -- bash -c " sed -i 's/tteck\\ /Proxmox/community-scripts\\ /ProxmoxVE/g' /usr/bin/update"
44+
45+ if pct exec " $container " -- grep -q " community-scripts/ProxmoxVE" /usr/bin/update; then
46+ echo -e " ${GN} [Success]${CL} /usr/bin/update updated in ${BL} $container ${CL} .\n"
47+ else
48+ echo -e " ${RD} [Error]${CL} /usr/bin/update in ${BL} $container ${CL} could not be updated properly.\n"
49+ fi
50+ fi
51+ else
52+ echo -e " ${RD} [Error]${CL} /usr/bin/update not found in container ${BL} $container ${CL} .\n"
53+ fi
54+ else
55+ echo -e " ${BL} [Info]${GN} Skipping ${BL} $container ${CL} (not Debian/Ubuntu)\n"
56+ fi
57+ }
58+
59+ header_info
60+ for container in $( pct list | awk ' {if(NR>1) print $1}' ) ; do
61+ update_container " $container "
62+ done
63+
64+ header_info
65+ echo -e " ${GN} The process is complete. The repositories have been switched to community-scripts/ProxmoxVE.${CL} \n"
0 commit comments