Update update-apps.sh
This commit is contained in:
parent
e94f2bf68e
commit
3c8184221a
@ -18,16 +18,16 @@ function header_info {
|
|||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
function detect_service(){
|
function detect_service() {
|
||||||
pushd $(mktemp -d) >/dev/null
|
pushd $(mktemp -d) >/dev/null
|
||||||
pct pull "$1" /usr/bin/update update 2>/dev/null
|
pct pull "$1" /usr/bin/update update 2>/dev/null
|
||||||
service=$(cat update | sed 's|.*/ct/||g' | sed 's|\.sh).*||g')
|
service=$(cat update | sed 's|.*/ct/||g' | sed 's|\.sh).*||g')
|
||||||
popd >/dev/null
|
popd >/dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
function backup_container(){
|
function backup_container() {
|
||||||
msg_info "Creating backup for container $1"
|
msg_info "Creating backup for container $1"
|
||||||
vzdump $1 --compress zstd --storage $STORAGE_CHOICE -notes-template "community-scripts backup updater" > /dev/null 2>&1
|
vzdump $1 --compress zstd --storage $STORAGE_CHOICE -notes-template "community-scripts backup updater" >/dev/null 2>&1
|
||||||
status=$?
|
status=$?
|
||||||
|
|
||||||
if [ $status -eq 0 ]; then
|
if [ $status -eq 0 ]; then
|
||||||
@ -38,8 +38,8 @@ function backup_container(){
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_backup_storages(){
|
function get_backup_storages() {
|
||||||
STORAGES=$(awk '
|
STORAGES=$(awk '
|
||||||
/^[a-z]+:/ {
|
/^[a-z]+:/ {
|
||||||
if (name != "") {
|
if (name != "") {
|
||||||
if (has_backup || (!has_content && type == "dir")) print name
|
if (has_backup || (!has_content && type == "dir")) print name
|
||||||
@ -87,7 +87,7 @@ while read -r container; do
|
|||||||
if pct config "$container_id" | grep -qE "^tags:.*(${TAGS}).*"; then
|
if pct config "$container_id" | grep -qE "^tags:.*(${TAGS}).*"; then
|
||||||
menu_items+=("$container_id" "$formatted_line" "OFF")
|
menu_items+=("$container_id" "$formatted_line" "OFF")
|
||||||
fi
|
fi
|
||||||
done <<< "$containers"
|
done <<<"$containers"
|
||||||
|
|
||||||
CHOICE=$(whiptail --title "LXC Container Update" \
|
CHOICE=$(whiptail --title "LXC Container Update" \
|
||||||
--checklist "Select LXC containers to update:" 25 60 13 \
|
--checklist "Select LXC containers to update:" 25 60 13 \
|
||||||
@ -101,12 +101,12 @@ fi
|
|||||||
|
|
||||||
header_info
|
header_info
|
||||||
BACKUP_CHOICE="no"
|
BACKUP_CHOICE="no"
|
||||||
if(whiptail --backtitle "Proxmox VE Helper Scripts" --title "LXC Container Update" --yesno "Do you want to backup your containers before update?" 10 58); then
|
if (whiptail --backtitle "Proxmox VE Helper Scripts" --title "LXC Container Update" --yesno "Do you want to backup your containers before update?" 10 58); then
|
||||||
BACKUP_CHOICE="yes"
|
BACKUP_CHOICE="yes"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
UNATTENDED_UPDATE="no"
|
UNATTENDED_UPDATE="no"
|
||||||
if(whiptail --backtitle "Proxmox VE Helper Scripts" --title "LXC Container Update" --yesno "Run updates unattended?" 10 58); then
|
if (whiptail --backtitle "Proxmox VE Helper Scripts" --title "LXC Container Update" --yesno "Run updates unattended?" 10 58); then
|
||||||
UNATTENDED_UPDATE="yes"
|
UNATTENDED_UPDATE="yes"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -133,7 +133,7 @@ if [ "$BACKUP_CHOICE" == "yes" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
UPDATE_CMD="update;"
|
UPDATE_CMD="update;"
|
||||||
if [ "$UNATTENDED_UPDATE" == "yes" ];then
|
if [ "$UNATTENDED_UPDATE" == "yes" ]; then
|
||||||
UPDATE_CMD="export PHS_SILENT=1;update;"
|
UPDATE_CMD="export PHS_SILENT=1;update;"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -141,7 +141,7 @@ containers_needing_reboot=()
|
|||||||
for container in $CHOICE; do
|
for container in $CHOICE; do
|
||||||
echo -e "${BL}[INFO]${CL} Updating container $container"
|
echo -e "${BL}[INFO]${CL} Updating container $container"
|
||||||
|
|
||||||
if [ "$BACKUP_CHOICE" == "yes" ];then
|
if [ "$BACKUP_CHOICE" == "yes" ]; then
|
||||||
backup_container $container
|
backup_container $container
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -213,7 +213,6 @@ for container in $CHOICE; do
|
|||||||
if [ "$UPDATE_BUILD_RESOURCES" -eq "1" ]; then
|
if [ "$UPDATE_BUILD_RESOURCES" -eq "1" ]; then
|
||||||
pct set "$container" --cores "$build_cpu" --memory "$build_ram"
|
pct set "$container" --cores "$build_cpu" --memory "$build_ram"
|
||||||
fi
|
fi
|
||||||
}
|
|
||||||
|
|
||||||
#4) Update service, using the update command
|
#4) Update service, using the update command
|
||||||
case "$os" in
|
case "$os" in
|
||||||
@ -243,11 +242,11 @@ for container in $CHOICE; do
|
|||||||
|
|
||||||
if [ $exit_code -eq 0 ]; then
|
if [ $exit_code -eq 0 ]; then
|
||||||
msg_ok "Updated container $container"
|
msg_ok "Updated container $container"
|
||||||
elif [ "BACKUP_CHOICE" == "yes" ];then
|
elif [ "$BACKUP_CHOICE" == "yes" ]; then
|
||||||
msg_info "Restoring LXC from backup"
|
msg_info "Restoring LXC from backup"
|
||||||
pct stop $container
|
pct stop $container
|
||||||
LXC_STORAGE=$(pct config $container | awk -F '[:,]' '/rootfs/ {print $2}')
|
LXC_STORAGE=$(pct config $container | awk -F '[:,]' '/rootfs/ {print $2}')
|
||||||
pct restore $container /var/lib/vz/dump/vzdump-lxc-${container}-*.tar.zst --storage $LXC_STORAGE --force > /dev/null 2>&1
|
pct restore $container /var/lib/vz/dump/vzdump-lxc-${container}-*.tar.zst --storage $LXC_STORAGE --force >/dev/null 2>&1
|
||||||
pct start $container
|
pct start $container
|
||||||
restorestatus=$?
|
restorestatus=$?
|
||||||
if [ $restorestatus -eq 0 ]; then
|
if [ $restorestatus -eq 0 ]; then
|
||||||
|
Loading…
x
Reference in New Issue
Block a user