Skip to content

Commit da92c7a

Browse files
authored
Add bashrc shortcut to update host
Once updated using this tool, a new command "proxmox-update" is available as a shortcut to update host, directly invoking proxmox-updater.sh script at https://raw.githubusercontent.com/Tontonjo/proxmox/master/proxmox_updater.sh.
1 parent 2b2a57b commit da92c7a

File tree

1 file changed

+38
-18
lines changed

1 file changed

+38
-18
lines changed

proxmox_toolbox.sh

+38-18
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
# Cosmetic corrections
4545

4646
# Proxmox_toolbox
47-
version=3.3
47+
version=3.4
4848
# V1.0: Initial Release
4949
# V1.1: correct detecition of subscription message removal
5050
# V2.0: Add backup and restore - reworked menu order - lots of small changes
@@ -58,6 +58,7 @@ version=3.3
5858
# V3.1: Merge backup folder in case there's pve and pbs on the same host - useless to have 2 content list
5959
# V3.2: Restauration now automatically remount directories and reimport existant zpools
6060
# V3.3: Add echo when restarting proxy services
61+
# V3.4: Add proxmox bashrc command to invoke update script usinge "proxmox-update"
6162

6263
# check if root
6364
if [[ $(id -u) -ne 0 ]] ; then echo "- Please run as root / sudo" ; exit 1 ; fi
@@ -87,7 +88,7 @@ main_menu(){
8788
echo -e "${MENU}********** https://www.youtube.com/c/tontonjo **************${NORMAL}"
8889
echo " "
8990
echo -e "${MENU}**${NUMBER} 1)${MENU} No-subscription Sources Configuration ${NORMAL}"
90-
echo -e "${MENU}**${NUMBER} 2)${MENU} Update host ${NORMAL}"
91+
echo -e "${MENU}**${NUMBER} 2)${MENU} Update host & Create bash.rc command${NORMAL}"
9192
echo -e "${MENU}**${NUMBER} 3)${MENU} Install usefull dependencies ${NORMAL}"
9293
echo -e "${MENU}**${NUMBER} 4)${MENU} Security settings (fail2ban & users)${NORMAL}"
9394
echo -e "${MENU}**${NUMBER} 5)${MENU} SWAP Settings ${NORMAL}"
@@ -152,23 +153,42 @@ main_menu(){
152153
main_menu
153154
;;
154155
2) clear;
155-
156-
echo "- Updating System"
157-
apt-get update -y -qq
158-
apt-get upgrade -y -qq
159-
apt-get dist-upgrade -y -qq
160-
if grep -Ewqi "no-subscription" /etc/apt/sources.list; then
161-
if grep -q ".data.status.toLowerCase() == 'active') {" $proxmoxlib; then
162-
echo "- Subscription Message already removed - Skipping"
163-
else
164-
if [ -d "$pve_log_folder" ]; then
165-
echo "- Removing No Valid Subscription Message for PVE"
166-
sed -Ezi.bak "s/!== 'active'/== 'active'/" $proxmoxlib && echo "- Restarting proxy service" && systemctl restart pveproxy.service
167-
else
168-
echo "- Removing No Valid Subscription Message for PBS"
169-
sed -Ezi.bak "s/!== 'active'/== 'active'/" $proxmoxlib && echo "- Restarting proxy service" && systemctl restart proxmox-backup-proxy.service
170-
fi
156+
# Check if the bashrc entry for update is already created
157+
if grep -Ewqi "proxmox-update" /$USER/.bashrc; then
158+
echo ""
159+
else
160+
# Test if bashrc file backup exist to ensure we're not overwriting the orgiginal - no matter what.
161+
if test -f "/$USER/.bashrc.BCK"; then
162+
echo "- Backup already exist"
163+
else
164+
echo "- Creating Backup"
165+
cp -n /$USER/.bashrc /$USER/.bashrc.BCK
171166
fi
167+
echo "- Adding command proxmox-update"
168+
echo "
169+
# Tonton Jo - Proxmox toolbox - used to update proxmox hosts
170+
proxmox-update() {
171+
wget -q -O - https://raw.githubusercontent.com/Tontonjo/proxmox/master/proxmox_updater.sh | bash
172+
}" >> /$USER/.bashrc
173+
echo "- Reloading bashrc - host can now be updated using command: proxmox-update"
174+
source ~/.bashrc
175+
fi
176+
echo "- Updating System"
177+
apt-get update -y -qq
178+
apt-get upgrade -y -qq
179+
apt-get dist-upgrade -y -qq
180+
if grep -Ewqi "no-subscription" /etc/apt/sources.list; then
181+
if grep -q ".data.status.toLowerCase() == 'active') {" $proxmoxlib; then
182+
echo "- Subscription Message already removed - Skipping"
183+
else
184+
if [ -d "$pve_log_folder" ]; then
185+
echo "- Removing No Valid Subscription Message for PVE"
186+
sed -Ezi.bak "s/!== 'active'/== 'active'/" $proxmoxlib && echo "- Restarting proxy service" && systemctl restart pveproxy.service
187+
else
188+
echo "- Removing No Valid Subscription Message for PBS"
189+
sed -Ezi.bak "s/!== 'active'/== 'active'/" $proxmoxlib && echo "- Restarting proxy service" && systemctl restart proxmox-backup-proxy.service
190+
fi
191+
fi
172192
sleep 3
173193
fi
174194
main_menu

0 commit comments

Comments
 (0)