mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2025-03-08 13:19:05 +00:00
[gh] Update Script Test Workflow (#2599)
* Update Workflow * Update Workflow
This commit is contained in:
parent
6827056a1d
commit
40469c5de5
35
.github/workflows/script-test.yml
vendored
35
.github/workflows/script-test.yml
vendored
@ -13,7 +13,7 @@ jobs:
|
|||||||
run-install-script:
|
run-install-script:
|
||||||
runs-on: pvenode
|
runs-on: pvenode
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout PR branch (supports forks)
|
- name: Checkout PR branch
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
ref: ${{ github.event.pull_request.head.ref }}
|
ref: ${{ github.event.pull_request.head.ref }}
|
||||||
@ -39,6 +39,7 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
|
||||||
- name: Get scripts
|
- name: Get scripts
|
||||||
id: check-install-script
|
id: check-install-script
|
||||||
run: |
|
run: |
|
||||||
@ -68,11 +69,11 @@ jobs:
|
|||||||
echo "Running Test for: $STRIPPED_NAME"
|
echo "Running Test for: $STRIPPED_NAME"
|
||||||
if [[ $FILE =~ ^install/.*-install\.sh$ ]]; then
|
if [[ $FILE =~ ^install/.*-install\.sh$ ]]; then
|
||||||
CT_SCRIPT="ct/$STRIPPED_NAME.sh"
|
CT_SCRIPT="ct/$STRIPPED_NAME.sh"
|
||||||
|
echo $CT_SCRIPT
|
||||||
if [[ ! -f $CT_SCRIPT ]]; then
|
if [[ ! -f $CT_SCRIPT ]]; then
|
||||||
echo "No CT script found for $STRIPPED_NAME"
|
echo "No CT script found for $STRIPPED_NAME"
|
||||||
ERROR_MSG="No CT script found for $FILE"
|
ERROR_MSG="No CT script found for $FILE"
|
||||||
echo "$ERROR_MSG" > result_$STRIPPED_NAME.log
|
RUN=false
|
||||||
continue
|
|
||||||
fi
|
fi
|
||||||
echo "Found CT script for $STRIPPED_NAME"
|
echo "Found CT script for $STRIPPED_NAME"
|
||||||
chmod +x "$CT_SCRIPT"
|
chmod +x "$CT_SCRIPT"
|
||||||
@ -82,32 +83,19 @@ jobs:
|
|||||||
if [[ ! -f $INSTALL_SCRIPT ]]; then
|
if [[ ! -f $INSTALL_SCRIPT ]]; then
|
||||||
echo "No install script found for $STRIPPED_NAME"
|
echo "No install script found for $STRIPPED_NAME"
|
||||||
ERROR_MSG="No install script found for $FILE"
|
ERROR_MSG="No install script found for $FILE"
|
||||||
echo "$ERROR_MSG" > result_$STRIPPED_NAME.log
|
RUN=false
|
||||||
continue
|
|
||||||
fi
|
fi
|
||||||
echo "Found install script for $STRIPPED_NAME"
|
echo "Found install script for $STRIPPED_NAME"
|
||||||
chmod +x "$INSTALL_SCRIPT"
|
chmod +x "$INSTALL_SCRIPT"
|
||||||
RUNNING_FILE=$FILE
|
RUNNING_FILE=$FILE
|
||||||
fi
|
fi
|
||||||
git remote add community-scripts https://github.com/community-scripts/ProxmoxVE.git
|
if [[ $RUN != "false" ]]; then
|
||||||
git fetch community-scripts
|
|
||||||
rm -f .github/workflows/scripts/app-test/pr-build.func || true
|
|
||||||
rm -f .github/workflows/scripts/app-test/pr-install.func || true
|
|
||||||
rm -f .github/workflows/scripts/app-test/pr-alpine-install.func || true
|
|
||||||
rm -f .github/workflows/scripts/app-test/pr-create-lxc.sh || true
|
|
||||||
git checkout community-scripts/main -- .github/workflows/scripts/app-test/pr-build.func
|
|
||||||
git checkout community-scripts/main -- .github/workflows/scripts/app-test/pr-install.func
|
|
||||||
git checkout community-scripts/main -- .github/workflows/scripts/app-test/pr-alpine-install.func
|
|
||||||
git checkout community-scripts/main -- .github/workflows/scripts/app-test/pr-create-lxc.sh
|
|
||||||
chmod +x $RUNNING_FILE
|
chmod +x $RUNNING_FILE
|
||||||
chmod +x .github/workflows/scripts/app-test/pr-create-lxc.sh
|
sed -i 's|source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)|source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/.github/workflows/scripts/app-test/pr-build.func)|g' "$RUNNING_FILE"
|
||||||
chmod +x .github/workflows/scripts/app-test/pr-install.func
|
|
||||||
chmod +x .github/workflows/scripts/app-test/pr-alpine-install.func
|
|
||||||
chmod +x .github/workflows/scripts/app-test/pr-build.func
|
|
||||||
sed -i 's|source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)|source .github/workflows/scripts/app-test/pr-build.func|g' "$RUNNING_FILE"
|
|
||||||
echo "Executing $RUNNING_FILE"
|
echo "Executing $RUNNING_FILE"
|
||||||
ERROR_MSG=$(./$RUNNING_FILE 2>&1 > /dev/null)
|
ERROR_MSG=$(./$RUNNING_FILE 2>&1 > /dev/null)
|
||||||
echo "Finished running $FILE"
|
echo "Finished running $FILE"
|
||||||
|
fi
|
||||||
if [ -n "$ERROR_MSG" ]; then
|
if [ -n "$ERROR_MSG" ]; then
|
||||||
echo "ERROR in $STRIPPED_NAME: $ERROR_MSG"
|
echo "ERROR in $STRIPPED_NAME: $ERROR_MSG"
|
||||||
echo "$ERROR_MSG" > result_$STRIPPED_NAME.log
|
echo "$ERROR_MSG" > result_$STRIPPED_NAME.log
|
||||||
@ -127,10 +115,11 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
- name: Post error comments
|
- name: Post error comments
|
||||||
run: |
|
run: |
|
||||||
ERROR="false"
|
ERROR="false"
|
||||||
SEARCH_LINE=".github/workflows/scripts/app-test/pr-build.func: line 253:"
|
SEARCH_LINE=".github/workflows/scripts/app-test/pr-build.func: line 255"
|
||||||
for FILE in ${{ env.ALL_FILES }}; do
|
for FILE in ${{ env.ALL_FILES }}; do
|
||||||
STRIPPED_NAME=$(basename "$FILE" | sed 's/-install//' | sed 's/\.sh$//')
|
STRIPPED_NAME=$(basename "$FILE" | sed 's/-install//' | sed 's/\.sh$//')
|
||||||
if [[ ! -f result_$STRIPPED_NAME.log ]]; then
|
if [[ ! -f result_$STRIPPED_NAME.log ]]; then
|
||||||
@ -145,8 +134,6 @@ jobs:
|
|||||||
gh pr comment ${{ github.event.pull_request.number }} \
|
gh pr comment ${{ github.event.pull_request.number }} \
|
||||||
--repo ${{ github.repository }} \
|
--repo ${{ github.repository }} \
|
||||||
--body ":warning: The script _**$FILE**_ failed with the following message: <br> <div><strong>${CLEANED_ERROR_MSG}</strong></div>"
|
--body ":warning: The script _**$FILE**_ failed with the following message: <br> <div><strong>${CLEANED_ERROR_MSG}</strong></div>"
|
||||||
|
|
||||||
|
|
||||||
ERROR="true"
|
ERROR="true"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
@ -157,3 +144,5 @@ jobs:
|
|||||||
- name: Fail if error
|
- name: Fail if error
|
||||||
if: ${{ env.ERROR == 'true' }}
|
if: ${{ env.ERROR == 'true' }}
|
||||||
run: exit 1
|
run: exit 1
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# Copyright (c) 2021-2025 community-scripts ORG
|
# Copyright (c) 2021-2025 community-scripts ORG
|
||||||
# Author: michelroegl-brunner
|
# Author: Michel Roegl-Brunner (michelroegl-brunner)
|
||||||
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
|
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
|
||||||
|
|
||||||
color() {
|
color() {
|
||||||
@ -11,7 +11,7 @@ catch_errors() {
|
|||||||
trap 'error_handler $LINENO "$BASH_COMMAND"' ERR
|
trap 'error_handler $LINENO "$BASH_COMMAND"' ERR
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# This function handles errors
|
||||||
error_handler() {
|
error_handler() {
|
||||||
local line_number="$1"
|
local line_number="$1"
|
||||||
local command="$2"
|
local command="$2"
|
||||||
@ -84,5 +84,3 @@ motd_ssh() {
|
|||||||
customize() {
|
customize() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
16
.github/workflows/scripts/app-test/pr-build.func
vendored
16
.github/workflows/scripts/app-test/pr-build.func
vendored
@ -6,6 +6,7 @@
|
|||||||
variables() {
|
variables() {
|
||||||
NSAPP=$(echo ${APP,,} | tr -d ' ') # This function sets the NSAPP variable by converting the value of the APP variable to lowercase and removing any spaces.
|
NSAPP=$(echo ${APP,,} | tr -d ' ') # This function sets the NSAPP variable by converting the value of the APP variable to lowercase and removing any spaces.
|
||||||
var_install="${NSAPP}-install" # sets the var_install variable by appending "-install" to the value of NSAPP.
|
var_install="${NSAPP}-install" # sets the var_install variable by appending "-install" to the value of NSAPP.
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NEXTID=$(pvesh get /cluster/nextid)
|
NEXTID=$(pvesh get /cluster/nextid)
|
||||||
@ -20,10 +21,10 @@ base_settings() {
|
|||||||
DISK_SIZE="4"
|
DISK_SIZE="4"
|
||||||
CORE_COUNT="1"
|
CORE_COUNT="1"
|
||||||
RAM_SIZE="1024"
|
RAM_SIZE="1024"
|
||||||
VERBOSE="${1:-no}"
|
VERBOSE="no"
|
||||||
PW=""
|
PW=""
|
||||||
CT_ID=$NEXTID
|
CT_ID=$NEXTID
|
||||||
HN="Testing"
|
HN=$NSAPP
|
||||||
BRG="vmbr0"
|
BRG="vmbr0"
|
||||||
NET="dhcp"
|
NET="dhcp"
|
||||||
GATE=""
|
GATE=""
|
||||||
@ -146,9 +147,9 @@ build_container() {
|
|||||||
TEMP_DIR=$(mktemp -d)
|
TEMP_DIR=$(mktemp -d)
|
||||||
pushd $TEMP_DIR >/dev/null
|
pushd $TEMP_DIR >/dev/null
|
||||||
if [ "$var_os" == "alpine" ]; then
|
if [ "$var_os" == "alpine" ]; then
|
||||||
export FUNCTIONS_FILE_PATH="$(cat /root/actions-runner/_work/ProxmoxVE/ProxmoxVE/.github/workflows/scripts/app-test/pr-alpine-install.func)"
|
export FUNCTIONS_FILE_PATH="$(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/.github/workflows/scripts/app-test/pr-alpine-install.func)"
|
||||||
else
|
else
|
||||||
export FUNCTIONS_FILE_PATH="$(cat /root/actions-runner/_work/ProxmoxVE/ProxmoxVE/.github/workflows/scripts/app-test/pr-install.func)"
|
export FUNCTIONS_FILE_PATH="$(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/.github/workflows/scripts/app-test/pr-install.func)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
export CACHER="$APT_CACHER"
|
export CACHER="$APT_CACHER"
|
||||||
@ -182,9 +183,8 @@ build_container() {
|
|||||||
"
|
"
|
||||||
echo "Container ID: $CTID"
|
echo "Container ID: $CTID"
|
||||||
|
|
||||||
|
|
||||||
# This executes create_lxc.sh and creates the container and .conf file
|
# This executes create_lxc.sh and creates the container and .conf file
|
||||||
bash /root/actions-runner/_work/ProxmoxVE/ProxmoxVE/.github/workflows/scripts/app-test/pr-create-lxc.sh
|
bash -c "$(wget -qLO - https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/.github/workflows/scripts/app-test/pr-create-lxc.sh)"
|
||||||
|
|
||||||
LXC_CONFIG=/etc/pve/lxc/${CTID}.conf
|
LXC_CONFIG=/etc/pve/lxc/${CTID}.conf
|
||||||
if [ "$CT_TYPE" == "0" ]; then
|
if [ "$CT_TYPE" == "0" ]; then
|
||||||
@ -233,6 +233,7 @@ EOF
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# This starts the container and executes <app>-install.sh
|
# This starts the container and executes <app>-install.sh
|
||||||
msg_info "Starting LXC Container"
|
msg_info "Starting LXC Container"
|
||||||
pct start "$CTID"
|
pct start "$CTID"
|
||||||
@ -250,11 +251,10 @@ http://dl-cdn.alpinelinux.org/alpine/latest-stable/community
|
|||||||
EOF'
|
EOF'
|
||||||
pct exec "$CTID" -- ash -c "apk add bash >/dev/null"
|
pct exec "$CTID" -- ash -c "apk add bash >/dev/null"
|
||||||
fi
|
fi
|
||||||
lxc-attach -n "$CTID" -- bash -c "$(cat /root/actions-runner/_work/ProxmoxVE/ProxmoxVE/install/$var_install.sh)" $var_install.sh
|
lxc-attach -n "$CTID" -- bash -c "$(cat /root/actions-runner/_work/ProxmoxVE/ProxmoxVE/install/$var_install.sh)"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
description() {
|
description() {
|
||||||
IP=$(pct exec "$CTID" ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1)
|
IP=$(pct exec "$CTID" ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1)
|
||||||
return
|
|
||||||
}
|
}
|
@ -11,6 +11,7 @@ catch_errors() {
|
|||||||
trap 'error_handler $LINENO "$BASH_COMMAND"' ERR
|
trap 'error_handler $LINENO "$BASH_COMMAND"' ERR
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# This function handles errors
|
||||||
error_handler() {
|
error_handler() {
|
||||||
local exit_code="$?"
|
local exit_code="$?"
|
||||||
local line_number="$1"
|
local line_number="$1"
|
||||||
@ -39,7 +40,6 @@ msg_error() {
|
|||||||
echo -e "${msg}\n"
|
echo -e "${msg}\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VALIDCT=$(pvesm status -content rootdir | awk 'NR>1')
|
VALIDCT=$(pvesm status -content rootdir | awk 'NR>1')
|
||||||
if [ -z "$VALIDCT" ]; then
|
if [ -z "$VALIDCT" ]; then
|
||||||
msg_error "Unable to detect a valid Container Storage location."
|
msg_error "Unable to detect a valid Container Storage location."
|
||||||
@ -64,7 +64,10 @@ function select_storage() {
|
|||||||
CONTENT='vztmpl'
|
CONTENT='vztmpl'
|
||||||
CONTENT_LABEL='Container template'
|
CONTENT_LABEL='Container template'
|
||||||
;;
|
;;
|
||||||
*) false || { msg_error "Invalid storage class."; exit 201; };;
|
*) false || {
|
||||||
|
msg_error "Invalid storage class."
|
||||||
|
exit 201
|
||||||
|
} ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# This Queries all storage locations
|
# This Queries all storage locations
|
||||||
@ -90,13 +93,22 @@ function select_storage() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[ "${CTID:-}" ]] || {
|
||||||
|
msg_error "You need to set 'CTID' variable."
|
||||||
|
exit 203
|
||||||
|
}
|
||||||
|
[[ "${PCT_OSTYPE:-}" ]] || {
|
||||||
|
msg_error "You need to set 'PCT_OSTYPE' variable."
|
||||||
|
exit 204
|
||||||
|
}
|
||||||
|
|
||||||
|
# Test if ID is valid
|
||||||
|
[ "$CTID" -ge "100" ] || {
|
||||||
|
msg_error "ID cannot be less than 100."
|
||||||
|
exit 205
|
||||||
|
}
|
||||||
|
|
||||||
[[ "${CTID:-}" ]] || { msg_error "You need to set 'CTID' variable."; exit 203; }
|
# Test if ID is in use
|
||||||
[[ "${PCT_OSTYPE:-}" ]] || { msg_error "You need to set 'PCT_OSTYPE' variable."; exit 204; }
|
|
||||||
|
|
||||||
[ "$CTID" -ge "100" ] || { msg_error "ID cannot be less than 100."; exit 205; }
|
|
||||||
|
|
||||||
if pct status $CTID &>/dev/null; then
|
if pct status $CTID &>/dev/null; then
|
||||||
echo -e "ID '$CTID' is already in use."
|
echo -e "ID '$CTID' is already in use."
|
||||||
unset CTID
|
unset CTID
|
||||||
@ -110,10 +122,12 @@ CONTAINER_STORAGE=$(select_storage container) || exit
|
|||||||
|
|
||||||
pveam update >/dev/null
|
pveam update >/dev/null
|
||||||
|
|
||||||
|
|
||||||
TEMPLATE_SEARCH=${PCT_OSTYPE}-${PCT_OSVERSION:-}
|
TEMPLATE_SEARCH=${PCT_OSTYPE}-${PCT_OSVERSION:-}
|
||||||
mapfile -t TEMPLATES < <(pveam available -section system | sed -n "s/.*\($TEMPLATE_SEARCH.*\)/\1/p" | sort -t - -k 2 -V)
|
mapfile -t TEMPLATES < <(pveam available -section system | sed -n "s/.*\($TEMPLATE_SEARCH.*\)/\1/p" | sort -t - -k 2 -V)
|
||||||
[ ${#TEMPLATES[@]} -gt 0 ] || { msg_error "Unable to find a template when searching for '$TEMPLATE_SEARCH'."; exit 207; }
|
[ ${#TEMPLATES[@]} -gt 0 ] || {
|
||||||
|
msg_error "Unable to find a template when searching for '$TEMPLATE_SEARCH'."
|
||||||
|
exit 207
|
||||||
|
}
|
||||||
TEMPLATE="${TEMPLATES[-1]}"
|
TEMPLATE="${TEMPLATES[-1]}"
|
||||||
|
|
||||||
TEMPLATE_PATH="/var/lib/vz/template/cache/$TEMPLATE"
|
TEMPLATE_PATH="/var/lib/vz/template/cache/$TEMPLATE"
|
||||||
@ -121,28 +135,29 @@ TEMPLATE_PATH="/var/lib/vz/template/cache/$TEMPLATE"
|
|||||||
if ! pveam list "$TEMPLATE_STORAGE" | grep -q "$TEMPLATE"; then
|
if ! pveam list "$TEMPLATE_STORAGE" | grep -q "$TEMPLATE"; then
|
||||||
[[ -f "$TEMPLATE_PATH" ]] && rm -f "$TEMPLATE_PATH"
|
[[ -f "$TEMPLATE_PATH" ]] && rm -f "$TEMPLATE_PATH"
|
||||||
pveam download "$TEMPLATE_STORAGE" "$TEMPLATE" >/dev/null ||
|
pveam download "$TEMPLATE_STORAGE" "$TEMPLATE" >/dev/null ||
|
||||||
{ msg_error "A problem occurred while downloading the LXC template."; exit 208; }
|
{
|
||||||
|
msg_error "A problem occurred while downloading the LXC template."
|
||||||
|
exit 208
|
||||||
|
}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
grep -q "root:100000:65536" /etc/subuid || echo "root:100000:65536" >>/etc/subuid
|
grep -q "root:100000:65536" /etc/subuid || echo "root:100000:65536" >>/etc/subuid
|
||||||
grep -q "root:100000:65536" /etc/subgid || echo "root:100000:65536" >>/etc/subgid
|
grep -q "root:100000:65536" /etc/subgid || echo "root:100000:65536" >>/etc/subgid
|
||||||
|
|
||||||
PCT_OPTIONS=(${PCT_OPTIONS[@]:-${DEFAULT_PCT_OPTIONS[@]}})
|
PCT_OPTIONS=(${PCT_OPTIONS[@]:-${DEFAULT_PCT_OPTIONS[@]}})
|
||||||
[[ " ${PCT_OPTIONS[@]} " =~ " -rootfs " ]] || PCT_OPTIONS+=(-rootfs "$CONTAINER_STORAGE:${PCT_DISK_SIZE:-8}")
|
[[ " ${PCT_OPTIONS[@]} " =~ " -rootfs " ]] || PCT_OPTIONS+=(-rootfs "$CONTAINER_STORAGE:${PCT_DISK_SIZE:-8}")
|
||||||
|
|
||||||
|
|
||||||
if ! pct create "$CTID" "${TEMPLATE_STORAGE}:vztmpl/${TEMPLATE}" "${PCT_OPTIONS[@]}" &>/dev/null; then
|
if ! pct create "$CTID" "${TEMPLATE_STORAGE}:vztmpl/${TEMPLATE}" "${PCT_OPTIONS[@]}" &>/dev/null; then
|
||||||
[[ -f "$TEMPLATE_PATH" ]] && rm -f "$TEMPLATE_PATH"
|
[[ -f "$TEMPLATE_PATH" ]] && rm -f "$TEMPLATE_PATH"
|
||||||
|
|
||||||
|
|
||||||
pveam download "$TEMPLATE_STORAGE" "$TEMPLATE" >/dev/null ||
|
pveam download "$TEMPLATE_STORAGE" "$TEMPLATE" >/dev/null ||
|
||||||
{ msg_error "A problem occurred while re-downloading the LXC template."; exit 208; }
|
{
|
||||||
|
msg_error "A problem occurred while re-downloading the LXC template."
|
||||||
|
exit 208
|
||||||
|
}
|
||||||
|
|
||||||
if ! pct create "$CTID" "${TEMPLATE_STORAGE}:vztmpl/${TEMPLATE}" "${PCT_OPTIONS[@]}" &>/dev/null; then
|
if ! pct create "$CTID" "${TEMPLATE_STORAGE}:vztmpl/${TEMPLATE}" "${PCT_OPTIONS[@]}" &>/dev/null; then
|
||||||
msg_error "A problem occurred while trying to create container after re-downloading template."
|
msg_error "A problem occurred while trying to create container after re-downloading template."
|
||||||
exit 200
|
exit 200
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -1,24 +1,23 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# Copyright (c) 2021-2025 community-scripts ORG
|
# Copyright (c) 2021-2025 community-scripts ORG
|
||||||
# Author: michelroegl-brunner
|
# Author: Michel Roegl-Brunner (michelroegl-brunner)
|
||||||
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
|
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
|
||||||
|
|
||||||
color() {
|
color() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
SCRIPT_NAME="${BASH_SOURCE[0]:-unknown_script}"
|
|
||||||
catch_errors() {
|
catch_errors() {
|
||||||
set -Euoe pipefail
|
set -Euo pipefail
|
||||||
trap 'error_handler $LINENO "$BASH_COMMAND"' ERR
|
trap 'error_handler $LINENO "$BASH_COMMAND"' ERR
|
||||||
}
|
}
|
||||||
|
|
||||||
error_handler() {
|
error_handler() {
|
||||||
local line_number="$1"
|
local line_number="$1"
|
||||||
local command="$2"
|
local command="$2"
|
||||||
local error_message="$SCRIPT_NAME: Failure in line $line_number while executing command '$command'"
|
local error_message="Failure in line $line_number while executing command '$command'"
|
||||||
echo -e "\n$error_message"
|
echo -e "\n$error_message\n" >&2
|
||||||
exit 300
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
verb_ip6() {
|
verb_ip6() {
|
||||||
@ -26,6 +25,7 @@ verb_ip6() {
|
|||||||
silent() {
|
silent() {
|
||||||
"$@" >/dev/null 2>&1 || error_handler "${BASH_LINENO[0]}" "$*"
|
"$@" >/dev/null 2>&1 || error_handler "${BASH_LINENO[0]}" "$*"
|
||||||
}
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
msg_info() {
|
msg_info() {
|
||||||
@ -43,9 +43,11 @@ msg_error() {
|
|||||||
local msg="$1"
|
local msg="$1"
|
||||||
echo -e "${msg}\n"
|
echo -e "${msg}\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
RETRY_NUM=10
|
RETRY_NUM=10
|
||||||
RETRY_EVERY=3
|
RETRY_EVERY=3
|
||||||
setting_up_container() {
|
setting_up_container() {
|
||||||
|
|
||||||
sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen
|
sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen
|
||||||
locale_line=$(grep -v '^#' /etc/locale.gen | grep -E '^[a-zA-Z]' | awk '{print $1}' | head -n 1)
|
locale_line=$(grep -v '^#' /etc/locale.gen | grep -E '^[a-zA-Z]' | awk '{print $1}' | head -n 1)
|
||||||
echo "LANG=${locale_line}" >/etc/default/locale
|
echo "LANG=${locale_line}" >/etc/default/locale
|
||||||
@ -58,7 +60,6 @@ setting_up_container() {
|
|||||||
if [ "$(hostname -I)" != "" ]; then
|
if [ "$(hostname -I)" != "" ]; then
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
echo 1>&2 -en "No Network! "
|
|
||||||
sleep $RETRY_EVERY
|
sleep $RETRY_EVERY
|
||||||
done
|
done
|
||||||
if [ "$(hostname -I)" = "" ]; then
|
if [ "$(hostname -I)" = "" ]; then
|
||||||
@ -68,8 +69,6 @@ setting_up_container() {
|
|||||||
fi
|
fi
|
||||||
rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED
|
rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED
|
||||||
systemctl disable -q --now systemd-networkd-wait-online.service
|
systemctl disable -q --now systemd-networkd-wait-online.service
|
||||||
msg_ok "Set up Container OS"
|
|
||||||
msg_ok "Network Connected: $(hostname -I)"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
network_check() {
|
network_check() {
|
||||||
@ -79,11 +78,10 @@ network_check() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
update_os() {
|
update_os() {
|
||||||
msg_info "Updating Container OS"
|
export DEBIAN_FRONTEND=noninteractive
|
||||||
apt-get update
|
apt-get update >/dev/null 2>&1
|
||||||
apt-get -o Dpkg::Options::="--force-confold" -y dist-upgrade
|
apt-get -o Dpkg::Options::="--force-confold" -y dist-upgrade >/dev/null
|
||||||
rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED
|
rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED
|
||||||
msg_ok "Updated Container OS"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
motd_ssh() {
|
motd_ssh() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user