40
40
# Cosmetic corrections
41
41
42
42
# Proxmox_toolbox
43
- version=4.1.2
43
+ version=4.1.3
44
44
45
45
# V1.0: Initial Release
46
46
# V1.1: correct detecition of subscription message removal
@@ -79,6 +79,7 @@ version=4.1.2
79
79
# V4.1.0: Correction and optimisations in fail2ban setup
80
80
# V4.1.1: Important fix in permissions for ssh keys
81
81
# V4.1.2: Add Ceph enterprise list to ignored sources when using no-subcription
82
+ # V4.1.3: Add a function to restore a working self-signed certificate in case of mistake, replace sleep with a more permissive method
82
83
83
84
# check if root
84
85
if [[ $( id -u) -ne 0 ]] ; then echo " - Please run as root / sudo" ; exit 1 ; fi
@@ -97,13 +98,23 @@ hostname=$(hostname)
97
98
date=$( date +%Y_%m_%d-%H_%M_%S)
98
99
# ---------------END OF VARIABLES-----------------
99
100
101
+ wait_or_input () {
102
+ local timeout=30 # timeout
103
+ local input
104
+
105
+ if read -t " $timeout " -n 1 -p " - Continue: press any key or wait $timeout seconds... " input; then
106
+ echo " Key pressed: continuing"
107
+ else
108
+ echo " - No key pressed until $timeout tiemout. continuing..."
109
+ fi
110
+ }
111
+
100
112
if [ ! -f /root/proxmox_config_backups/$hostname -firstrun.tar.gz ]; then
101
113
echo " - Creating a backup at first run - dont delete it :-)"
102
114
mkdir -p /root/proxmox_config_backups/
103
- sleep 2
104
115
tar -czf /root/proxmox_config_backups/$hostname -firstrun.tar.gz --absolute-names $backup_content
105
116
echo " - First run: a backup of the actual configurations has been created at /root/proxmox_config_backups/$hostname -firstrun.tar.gz"
106
- sleep 2
117
+ wait_or_input
107
118
fi
108
119
109
120
update () {
@@ -140,7 +151,7 @@ getcontentcheck() {
140
151
exitcode=$?
141
152
if [ $exitcode -ne 0 ]; then
142
153
echo " - Error retreiving ressources - control your internet connexion"
143
- sleep 7
154
+ wait_or_input
144
155
main_menu
145
156
fi
146
157
}
@@ -234,13 +245,13 @@ main_menu(){
234
245
sed -i ' s/^/#/' /etc/apt/sources.list.d/pbs-enterprise.list
235
246
fi
236
247
fi
237
- sleep 3
248
+ wait_or_input
238
249
fi
239
250
main_menu
240
251
;;
241
252
2) clear;
242
253
update
243
- sleep 3
254
+ wait_or_input
244
255
main_menu
245
256
;;
246
257
3) clear;
@@ -279,7 +290,7 @@ main_menu(){
279
290
else
280
291
echo " - lm-sensors already installed"
281
292
fi
282
- sleep 3
293
+ wait_or_input
283
294
fi
284
295
main_menu
285
296
;;
@@ -323,7 +334,6 @@ main_menu(){
323
334
systemctl restart fail2ban.service
324
335
echo " - Cleaning git ressources"
325
336
rm -rf ./proxmox_toolbox/
326
-
327
337
fi
328
338
clear
329
339
echo " - Do you want to create another SSH user ?"
@@ -383,7 +393,7 @@ main_menu(){
383
393
pveum user modify $pveusername @pve -group $admingroup
384
394
clear
385
395
echo " - You can now login on GUI with $pveusername @Proxmox VE authenticaton Realm"
386
- sleep 2
396
+ wait_or_input
387
397
echo " "
388
398
echo " !! Warning - root@pam is required to update host from Proxmox web ui !!"
389
399
read -p " - Do you want to disable " root@pam" ? y = yes / anything = no: " -n 1 -r
@@ -423,11 +433,11 @@ main_menu(){
423
433
swapoff -a
424
434
echo " - Re-enabling with a swapiness of: $newswapvalue "
425
435
swapon -a
426
- sleep 3
436
+ wait_or_input
427
437
fi
428
438
else
429
439
echo " - System has no swap - Nothing to do"
430
- sleep 7
440
+ wait_or_input
431
441
fi
432
442
main_menu
433
443
;;
@@ -444,7 +454,7 @@ main_menu(){
444
454
echo " - Short smart test will occure every sunday at 22H and long smart tests every 1 of month at 22H"
445
455
echo " DEVICESCAN -d auto -n never -a -s (S/../../7/22|L/../01/./22) -m root -M exec /usr/share/smartmontools/smartd-runner" > " /etc/smartd.conf"
446
456
fi
447
- sleep 7
457
+ wait_or_input
448
458
fi
449
459
main_menu
450
460
;;
@@ -490,11 +500,11 @@ main_menu(){
490
500
else
491
501
clear
492
502
echo " - Returning to menu - no valid choice selected"
493
- sleep 7
503
+ wait_or_input
494
504
main_menu
495
505
fi
496
506
systemctl restart snmpd
497
- sleep 3
507
+ wait_or_input
498
508
fi
499
509
main_menu
500
510
;;
@@ -650,7 +660,6 @@ mail_menu(){
650
660
else
651
661
postconf sender_canonical_maps=hash:/etc/postfix/canonical
652
662
fi
653
-
654
663
echo " - Encrypting password and canonical entry"
655
664
postmap /etc/postfix/sasl_passwd
656
665
postmap /etc/postfix/canonical
@@ -659,7 +668,7 @@ mail_menu(){
659
668
echo " - Cleaning file used to generate password hash"
660
669
rm -rf " /etc/postfix/sasl_passwd"
661
670
echo " - Files cleaned"
662
-
671
+ wait_or_input
663
672
mail_menu;
664
673
;;
665
674
@@ -669,7 +678,7 @@ mail_menu(){
669
678
echo " - An email will be sent to: $vardestaddress "
670
679
echo “If you reveive this, it means your email configurations looks correct. Yay! ” | mail -s " test mail - $hostname - $date " $vardestaddress
671
680
echo " - Email should have been sent - If none received, you may want to check for errors in menu 3"
672
- sleep 3
681
+ wait_or_input
673
682
674
683
mail_menu;
675
684
;;
@@ -723,7 +732,7 @@ mail_menu(){
723
732
fi
724
733
else
725
734
echo " - No configured error found - nothing to do!"
726
- sleep 3
735
+ wait_or_input
727
736
fi
728
737
mail_menu;
729
738
;;
@@ -737,6 +746,7 @@ mail_menu(){
737
746
echo " - Restarting services "
738
747
systemctl restart postfix
739
748
echo " - Restoration done"
749
+ wait_or_input
740
750
fi
741
751
mail_menu;
742
752
;;
@@ -773,6 +783,7 @@ backup_menu(){
773
783
echo " "
774
784
echo -e " ${MENU} **${NUMBER} 1)${MENU} Backup configuration ${NORMAL} "
775
785
echo -e " ${MENU} **${NUMBER} 2)${MENU} Restore configuration ${NORMAL} "
786
+ echo -e " ${MENU} **${NUMBER} 3)${MENU} Restore a Self signed certificate ${NORMAL} "
776
787
echo -e " ${MENU} **${NUMBER} 0)${MENU} Back ${NORMAL} "
777
788
echo " "
778
789
echo -e " ${MENU} *********************************************${NORMAL} "
@@ -791,7 +802,7 @@ backup_menu(){
791
802
clear
792
803
echo " - Backup done - please control and test it"
793
804
echo " - Archive is located in $backupdir "
794
- sleep 7
805
+ wait_or_input
795
806
clear
796
807
backup_menu
797
808
;;
@@ -851,6 +862,7 @@ backup_menu(){
851
862
echo " - Importing pool $pool "
852
863
zpool import -f $pool
853
864
done
865
+ wait_or_input
854
866
read -p " - Do you want to reboot host now? y = yes / anything = no: " -n 1 -r
855
867
if [[ $REPLY =~ ^[Yy]$ ]]; then
856
868
reboot now
@@ -871,6 +883,18 @@ backup_menu(){
871
883
esac
872
884
done
873
885
;;
886
+ 3) clear;
887
+ echo " - Removing old certificates "
888
+ rm -f /etc/pve/pve-root-ca.pem
889
+ rm -f /etc/pve/priv/pve-root-ca.key
890
+ rm -f /etc/pve/nodes/$hostname /pve-ssl.pem
891
+ rm -f /etc/pve/nodes/$hostname /pve-ssl.key
892
+ echo " - Generating new certificates"
893
+ pvecm updatecerts -f
894
+ wait_or_input
895
+ clear
896
+ backup_menu
897
+ ;;
874
898
0) clear;
875
899
main_menu;
876
900
;;
0 commit comments