From de140fa55cc99d362b05659ee2bff1d62bdc8c43 Mon Sep 17 00:00:00 2001 From: mckaygerhard Date: Wed, 8 Jan 2025 10:16:26 -0400 Subject: [PATCH 1/9] update openrc gentoo based outdated script in sync with current gentoo * This script its from ancient webmin era.. we need up to date to be able to use for alpine and modern gentoo linux distributions, gentoo still uses Openrc for many things no matter if you choose other init systems * Fix status command not available to, by the detection of the pid, this is using the config pid variable from webmin config miniserv is need for future support on issue #2353 and related to #835 that just assume init sysv systems or the other s*** only. Still is pending future support for openrc init system but with this path next changes are more easy to do --- webmin-gentoo-init | 51 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 42 insertions(+), 9 deletions(-) diff --git a/webmin-gentoo-init b/webmin-gentoo-init index 09e381361..705360acb 100755 --- a/webmin-gentoo-init +++ b/webmin-gentoo-init @@ -1,19 +1,52 @@ -#!/sbin/runscript -# Copyright 1999-2002 Gentoo Technologies, Inc. +#!/sbin/openrc-run + +# Copyright 2024 webmin & mckaygerhard # Distributed under the terms of the GNU General Public License, v2 or later + +name="webmin" +# config file must be in sync with setup script, so i will not touch cos process will be the same as webmin-systemd +# like calling updateboot.pl with a new procedure method defined as openrc and not just assumed sysvinit if not systemd is present +# and also atboot.pl with new procedure for openrc the alpine linux init system at the moment +#conf_file="WEBMIN_CONFIG/miniserv.conf" +conf_file="/etc/webmin/miniserv.conf" + + depend() { - need net logger + need logger localmount + use net + after bootmisc } start() { - ebegin "Starting webmin" - /etc/webmin/start - eend $? +# same problem here.. we need to use WEBMIN_CONFIG variable to find the start script +# WEBMIN_CONFIG/start + /etc/webmin/start + eend $? } stop() { - ebegin "Stopping webmin" - /etc/webmin/stop - eend $? +# same problem here.. we need to use WEBMIN_CONFIG variable to find the stop script +# WEBMIN_CONFIG/stop + /etc/webmin/stop + eend $? +} + +status() { + pidfile=`grep "^pidfile=" "${conf_file}" | sed -e 's/pidfile=//g'` + if [ -s $pidfile ]; then + pid=`cat $pidfile` + kill -0 $pid >/dev/null 2>&1 + if [ "$?" = "0" ]; then + einfo "webmin (pid $pid) is running" + return 0 + else + einfo "webmin is stopped" + return 0 + fi + else + einfo "webmin is stopped" + return 0 + fi + } From 8223f24b2b0fcc23259a2ea027e12e67846b6f22 Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Thu, 9 Jan 2025 04:14:24 +0200 Subject: [PATCH 2/9] Fix to test new master template with tagged releases support --- .github/workflows/webmin.dev:webmin.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/webmin.dev:webmin.yml b/.github/workflows/webmin.dev:webmin.yml index c48e952fa..352ed9faf 100644 --- a/.github/workflows/webmin.dev:webmin.yml +++ b/.github/workflows/webmin.dev:webmin.yml @@ -4,18 +4,22 @@ on: push: branches: - master + tags: + - '*' jobs: build: - uses: webmin/webmin-ci-cd/.github/workflows/testing-master-workflow.yml@main + uses: webmin/webmin-ci-cd/.github/workflows/master-workflow.yml@main with: build-type: package project-name: webmin + tagged-release: ${{ startsWith(github.ref, 'refs/tags/') }} secrets: DEV_GPG_PH: ${{ secrets.DEV_GPG_PH }} DEV_IP_ADDR: ${{ secrets.DEV_IP_ADDR }} DEV_IP_KNOWN_HOSTS: ${{ secrets.DEV_IP_KNOWN_HOSTS }} DEV_UPLOAD_SSH_USER: ${{ secrets.DEV_UPLOAD_SSH_USER }} DEV_UPLOAD_SSH_DIR: ${{ secrets.DEV_UPLOAD_SSH_DIR }} + PRERELEASE_UPLOAD_SSH_DIR: ${{ secrets.PRERELEASE_UPLOAD_SSH_DIR }} DEV_SSH_PRV_KEY: ${{ secrets.DEV_SSH_PRV_KEY }} DEV_SIGN_BUILD_REPOS_CMD: ${{ secrets.DEV_SIGN_BUILD_REPOS_CMD }} From 16df7857a4960b2f090b436856656e7e79447841 Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Thu, 9 Jan 2025 04:15:33 +0200 Subject: [PATCH 3/9] Dev: Force tagged release for testing --- .github/workflows/webmin.dev:webmin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/webmin.dev:webmin.yml b/.github/workflows/webmin.dev:webmin.yml index 352ed9faf..beaf88809 100644 --- a/.github/workflows/webmin.dev:webmin.yml +++ b/.github/workflows/webmin.dev:webmin.yml @@ -13,7 +13,7 @@ jobs: with: build-type: package project-name: webmin - tagged-release: ${{ startsWith(github.ref, 'refs/tags/') }} + tagged-release: true secrets: DEV_GPG_PH: ${{ secrets.DEV_GPG_PH }} DEV_IP_ADDR: ${{ secrets.DEV_IP_ADDR }} From 5478a4fc87cea4b1065f827b8f3b71e5d0b4cdb5 Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Thu, 9 Jan 2025 04:30:09 +0200 Subject: [PATCH 4/9] Dev: Revert to build on tag as all works fine now [no-build] --- .github/workflows/webmin.dev:webmin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/webmin.dev:webmin.yml b/.github/workflows/webmin.dev:webmin.yml index beaf88809..352ed9faf 100644 --- a/.github/workflows/webmin.dev:webmin.yml +++ b/.github/workflows/webmin.dev:webmin.yml @@ -13,7 +13,7 @@ jobs: with: build-type: package project-name: webmin - tagged-release: true + tagged-release: ${{ startsWith(github.ref, 'refs/tags/') }} secrets: DEV_GPG_PH: ${{ secrets.DEV_GPG_PH }} DEV_IP_ADDR: ${{ secrets.DEV_IP_ADDR }} From 1ceabeb841f7d6a2df567bd8414bb79d7e5540f7 Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Fri, 10 Jan 2025 03:05:46 +0200 Subject: [PATCH 5/9] Fix workflow to correctly trigger workflow on release --- .github/workflows/webmin.dev:webmin.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/webmin.dev:webmin.yml b/.github/workflows/webmin.dev:webmin.yml index 352ed9faf..fcada5702 100644 --- a/.github/workflows/webmin.dev:webmin.yml +++ b/.github/workflows/webmin.dev:webmin.yml @@ -4,8 +4,10 @@ on: push: branches: - master - tags: - - '*' + release: + types: + - published + - edited jobs: build: @@ -13,7 +15,7 @@ jobs: with: build-type: package project-name: webmin - tagged-release: ${{ startsWith(github.ref, 'refs/tags/') }} + is-release: ${{ github.event_name == 'release' }} secrets: DEV_GPG_PH: ${{ secrets.DEV_GPG_PH }} DEV_IP_ADDR: ${{ secrets.DEV_IP_ADDR }} From 23aa974014be1e901970ede9d18ebd212367db79 Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Fri, 10 Jan 2025 16:36:53 +0200 Subject: [PATCH 6/9] Fix typo --- webmin/edit_ssl.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webmin/edit_ssl.cgi b/webmin/edit_ssl.cgi index c204a64a1..c7ae7d4dc 100755 --- a/webmin/edit_ssl.cgi +++ b/webmin/edit_ssl.cgi @@ -288,7 +288,7 @@ else { my $hasapache = &foreign_installed("apache"); my $mode = $webroot eq 'dns' ? 3 : $webroot ? 2 : - $hasapacehe ? 0 : + $hasapache ? 0 : $letsencrypt_cmd ? 4 : 2; if ($hasapache) { &foreign_require("apache"); From ed3138908745b7e692f36accaefa036b4d6c3429 Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Sat, 11 Jan 2025 04:46:40 +0200 Subject: [PATCH 7/9] Add ability to exclude packages if defined --- webmin-setup-repo.sh | 64 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 63 insertions(+), 1 deletion(-) diff --git a/webmin-setup-repo.sh b/webmin-setup-repo.sh index dc0868d5d..b4c6d744c 100644 --- a/webmin-setup-repo.sh +++ b/webmin-setup-repo.sh @@ -66,6 +66,7 @@ Repository configuration: --key-suffix= Repository key suffix for file naming --auth-user= Repository authentication username --auth-pass= Repository authentication password + --pkg-excl= Package name to exclude Repository metadata: --name= Base name for repository (default: webmin) @@ -130,6 +131,9 @@ process_args() { --auth-pass=*) repo_auth_pass="${arg#*=}" ;; + --pkg-excl=*) + repo_pkg_prio="${arg#*=}" + ;; --name=*) base_name="${arg#*=}" repo_name="$base_name" @@ -326,6 +330,28 @@ check_gpg() { fi } +enforce_package_priority() { + repo_pkg_priority=$1 + target=$2 + + # Extract the relevant entry for the target + match=$(echo "$repo_pkg_priority" | grep -o "${target}:[^ =]*[^ ]*") + + if [ -n "$match" ]; then + # Extract the package name + package=$(echo "$match" | sed -e "s/^${target}:\([^=]*\).*/\1/") + # Extract the priority and version parameters (if present) + priority=$(echo "$match" | sed -n -e "s/^${target}:[^=]*=\([^=]*\)=.*$/\1/p") + version=$(echo "$match" | sed -n -e "s/^${target}:[^=]*=[^=]*=\(.*\)$/\1/p") + + # Output package, priority, and version parameters (empty if not present) + echo "$package ${priority:-} ${version:-}" + return 0 + fi + + return 1 +} + download_key() { rm -f "/tmp/$repo_key" echo " Downloading Webmin developers key .." @@ -353,6 +379,20 @@ setup_repos() { cp -f "$repo_key" \ "/etc/pki/rpm-gpg/RPM-GPG-KEY-$repo_key_suffix" echo " .. done" + # Configure packages priority if provided + if [ -n "$repo_pkg_prio" ]; then + repo_pkg_prio_rs=$(enforce_package_priority "$repo_pkg_prio" "rpm") + if [ $? -eq 0 ]; then + echo " Setting up package exclusion for repository .." + package=$(echo "$repo_pkg_prio_rs" | awk '{print $1}') + repo_extra_opts="exclude=$package" + echo " .. done" + else + echo " Cleaning up package priority configuration .." + echo " .. done" + fi + fi + # Configure the repository echo " Setting up ${repo_desc_formatted} repository .." if [ "$repo_mode" = "stable" ]; then repo_url="$active_repo_download/download/newkey/yum" @@ -384,6 +424,28 @@ EOF post_status $? sources_list=$(grep -v "$repo_host" /etc/apt/sources.list) echo "$sources_list" > /etc/apt/sources.list + # Configure packages priority if provided + debian_repo_prefs="/etc/apt/preferences.d/$repoid_debian_like-$repo_dist-package-priority" + if [ -n "$repo_pkg_prio" ]; then + repo_pkg_prio_rs=$(enforce_package_priority "$repo_pkg_prio" "deb") + if [ $? -eq 0 ]; then + echo " Setting up package priority for repository .." + package=$(echo "$repo_pkg_prio_rs" | awk '{print $1}') + priority=$(echo "$repo_pkg_prio_rs" | awk '{print $2}') + version=$(echo "$repo_pkg_prio_rs" | awk '{print $3}') + cat << EOF > "$debian_repo_prefs" +Package: $package +Pin: version /$version\$/ +Pin-Priority: $priority +EOF + echo " .. done" + fi + else + echo " Cleaning up package priority configuration .." + rm -f "$debian_repo_prefs" + echo " .. done" + fi + # Configure the repository echo " Setting up ${repo_desc_formatted} repository .." if [ "$repo_mode" = "stable" ]; then repo_line="deb [signed-by=/usr/share/keyrings/$repoid_debian_like-$repo_key_suffix.gpg] \ @@ -410,8 +472,8 @@ $active_repo_download $repo_dist $repo_component" echo "machine $auth_domain login $repo_auth_user password $repo_auth_pass" >> "$auth_file" chmod 600 "$auth_file" fi - echo " .. done" + echo " Cleaning repository metadata .." $clean 1>/dev/null 2>&1 echo " .. done" From ec4b3317095b0af465cdc8349f71e2cc1fd5456f Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Sat, 11 Jan 2025 04:52:01 +0200 Subject: [PATCH 8/9] Fix repo name consistency --- webmin-setup-repo.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/webmin-setup-repo.sh b/webmin-setup-repo.sh index b4c6d744c..057d52680 100644 --- a/webmin-setup-repo.sh +++ b/webmin-setup-repo.sh @@ -20,7 +20,7 @@ repo_dist="stable" repo_section="contrib" repo_description="Webmin Releases" repo_description_prerelease="Webmin Prerelease" -repo_description_unstable="Webmin Development Builds" +repo_description_unstable="Webmin Unstable" install_check_binary="/usr/bin/webmin" install_message="Webmin and Usermin can be installed with:" install_packages="webmin usermin" @@ -144,7 +144,7 @@ process_args() { base_description="${arg#*=}" repo_description="$base_description Releases" repo_description_prerelease="${base_description} Prerelease" - repo_description_unstable="${base_description} Development Builds" + repo_description_unstable="${base_description} Unstable" ;; --component=*) repo_component="${arg#*=}" From 7eb8e4d336d39e02976c9640ef96048167b3d232 Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Sat, 11 Jan 2025 05:31:14 +0200 Subject: [PATCH 9/9] Fix to improve new params names --- webmin-setup-repo.sh | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/webmin-setup-repo.sh b/webmin-setup-repo.sh index 057d52680..88c209712 100644 --- a/webmin-setup-repo.sh +++ b/webmin-setup-repo.sh @@ -66,7 +66,7 @@ Repository configuration: --key-suffix= Repository key suffix for file naming --auth-user= Repository authentication username --auth-pass= Repository authentication password - --pkg-excl= Package name to exclude + --pkg-prefs= Package preferences for repository Repository metadata: --name= Base name for repository (default: webmin) @@ -131,8 +131,8 @@ process_args() { --auth-pass=*) repo_auth_pass="${arg#*=}" ;; - --pkg-excl=*) - repo_pkg_prio="${arg#*=}" + --pkg-prefs=*) + repo_pkg_prefs="${arg#*=}" ;; --name=*) base_name="${arg#*=}" @@ -331,18 +331,18 @@ check_gpg() { } enforce_package_priority() { - repo_pkg_priority=$1 - target=$2 + repo_pkg_pref=$1 + disttarget=$2 - # Extract the relevant entry for the target - match=$(echo "$repo_pkg_priority" | grep -o "${target}:[^ =]*[^ ]*") + # Extract the relevant entries for the target distribution + match=$(echo "$repo_pkg_pref" | grep -o "${disttarget}:[^ =]*[^ ]*") if [ -n "$match" ]; then # Extract the package name - package=$(echo "$match" | sed -e "s/^${target}:\([^=]*\).*/\1/") + package=$(echo "$match" | sed -e "s/^${disttarget}:\([^=]*\).*/\1/") # Extract the priority and version parameters (if present) - priority=$(echo "$match" | sed -n -e "s/^${target}:[^=]*=\([^=]*\)=.*$/\1/p") - version=$(echo "$match" | sed -n -e "s/^${target}:[^=]*=[^=]*=\(.*\)$/\1/p") + priority=$(echo "$match" | sed -n -e "s/^${disttarget}:[^=]*=\([^=]*\)=.*$/\1/p") + version=$(echo "$match" | sed -n -e "s/^${disttarget}:[^=]*=[^=]*=\(.*\)$/\1/p") # Output package, priority, and version parameters (empty if not present) echo "$package ${priority:-} ${version:-}" @@ -380,11 +380,11 @@ setup_repos() { "/etc/pki/rpm-gpg/RPM-GPG-KEY-$repo_key_suffix" echo " .. done" # Configure packages priority if provided - if [ -n "$repo_pkg_prio" ]; then - repo_pkg_prio_rs=$(enforce_package_priority "$repo_pkg_prio" "rpm") + if [ -n "$repo_pkg_prefs" ]; then + repo_pkg_prefs_rs=$(enforce_package_priority "$repo_pkg_prefs" "rpm") if [ $? -eq 0 ]; then echo " Setting up package exclusion for repository .." - package=$(echo "$repo_pkg_prio_rs" | awk '{print $1}') + package=$(echo "$repo_pkg_prefs_rs" | awk '{print $1}') repo_extra_opts="exclude=$package" echo " .. done" else @@ -426,13 +426,13 @@ EOF echo "$sources_list" > /etc/apt/sources.list # Configure packages priority if provided debian_repo_prefs="/etc/apt/preferences.d/$repoid_debian_like-$repo_dist-package-priority" - if [ -n "$repo_pkg_prio" ]; then - repo_pkg_prio_rs=$(enforce_package_priority "$repo_pkg_prio" "deb") + if [ -n "$repo_pkg_prefs" ]; then + repo_pkg_prefs_rs=$(enforce_package_priority "$repo_pkg_prefs" "deb") if [ $? -eq 0 ]; then echo " Setting up package priority for repository .." - package=$(echo "$repo_pkg_prio_rs" | awk '{print $1}') - priority=$(echo "$repo_pkg_prio_rs" | awk '{print $2}') - version=$(echo "$repo_pkg_prio_rs" | awk '{print $3}') + package=$(echo "$repo_pkg_prefs_rs" | awk '{print $1}') + priority=$(echo "$repo_pkg_prefs_rs" | awk '{print $2}') + version=$(echo "$repo_pkg_prefs_rs" | awk '{print $3}') cat << EOF > "$debian_repo_prefs" Package: $package Pin: version /$version\$/