-
-
Notifications
You must be signed in to change notification settings - Fork 472
New Add-On for step-ca: step-admin #1736
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 4 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
d3a1875
Initial commit of step-admin
heinemannj 5c383c8
Update step-admin.sh
heinemannj 944bf91
Update step-admin.sh
heinemannj 3bbac8f
Update whiptail.func
heinemannj 017b3e5
Refactor step-admin.sh to include whiptail functions
heinemannj 7ddc172
Delete misc/admin-core.func misc/whiptail.func
heinemannj 50d6745
Delete misc/whiptail.func
heinemannj 6d03f59
Add step-admin header file
heinemannj c6df615
Use header_info function from sources
heinemannj 98e28c4
Update step-admin.sh
heinemannj 0d7a93e
Remove header_info function and comments
heinemannj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| #!/usr/bin/env bash | ||
| # Copyright (c) 2021-2026 community-scripts ORG | ||
| # Author: community-scripts ORG | ||
| # License: MIT | https://github.com/community-scripts/ProxmoxVED/raw/branch/main/LICENSE | ||
|
|
||
| #function die() { | ||
| # msg_error "${1}"; exit 1 | ||
| #} | ||
|
|
||
| # ============================================================================== | ||
| # OS DETECTION | ||
| # ============================================================================== | ||
| function detect_os() { | ||
| if grep -qi "alpine" /etc/os-release; then | ||
| #OS="Alpine" | ||
| PKG_UPDATE="" | ||
| PKG_INSTALL="apk add --no-cache" | ||
| PKG_UPGRADE="apk update" | ||
| PKG_UNINSTALL="apk del" | ||
| PKG_AUTOREMOVE="" | ||
| elif grep -qi "arch" /etc/os-release; then | ||
| #OS="Arch" | ||
| PKG_UPDATE="" | ||
| PKG_INSTALL="pacman -S" | ||
| PKG_UPGRADE="pacman -Syu" | ||
| PKG_UNINSTALL="pacman -Rs" | ||
| PKG_AUTOREMOVE="" | ||
| elif grep -qi "debian" /etc/os-release; then | ||
| #OS="Debian" | ||
| PKG_UPDATE="apt update" | ||
| PKG_INSTALL="apt -y install" | ||
| PKG_UPGRADE="apt -y upgrade" | ||
| PKG_UNINSTALL="apt -y --purge remove" | ||
| PKG_AUTOREMOVE="apt -y --purge autoremove" | ||
| if ! [[ -f /etc/apt/sources.list.d/smallstep.sources ]]; then | ||
| setup_deb822_repo \ | ||
| "smallstep" \ | ||
| "https://packages.smallstep.com/keys/apt/repo-signing-key.gpg" \ | ||
| "https://packages.smallstep.com/stable/debian" \ | ||
| "debs" \ | ||
| "main" | ||
| fi | ||
| elif grep -qi "ubuntu" /etc/os-release; then | ||
| #OS="Ubuntu" | ||
| PKG_UPDATE="apt update" | ||
| PKG_INSTALL="apt -y install" | ||
| PKG_UPGRADE="apt -y upgrade" | ||
| PKG_UNINSTALL="apt -y --purge remove" | ||
| PKG_AUTOREMOVE="apt -y --purge autoremove" | ||
| if ! [[ -f /etc/apt/sources.list.d/smallstep.sources ]]; then | ||
| setup_deb822_repo \ | ||
| "smallstep" \ | ||
| "https://packages.smallstep.com/keys/apt/repo-signing-key.gpg" \ | ||
| "https://packages.smallstep.com/stable/debian" \ | ||
| "debs" \ | ||
| "main" | ||
| fi | ||
| else | ||
| die "Unsupported OS. Exiting." | ||
| fi | ||
| } | ||
|
|
||
| # ============================================================================== | ||
| # HELPER FUNCTIONS | ||
| # ============================================================================== | ||
| function resolve_ip() { | ||
| local FQDN=$1 | ||
| local IP | ||
| IP=$(dig +short "$FQDN") | ||
| [[ -z "$IP" ]] && exit 1 || echo "$IP" | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,155 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| # Copyright (c) 2021-2026 community-scripts ORG | ||
| # Author: community-scripts ORG | ||
| # License: MIT | https://github.com/community-scripts/ProxmoxVED/raw/branch/main/LICENSE | ||
|
|
||
| # ============================================================================== | ||
| # WHIPTAIL HELPER FUNCTIONS | ||
| # ============================================================================== | ||
| # | ||
| # This file contains several whiptail functions for displaying dialog boxes in the terminal. | ||
| # | ||
| # Whenever possible the dialog box | ||
| # - width is automatically calculated based on the length of the title, text, tag, item and status. | ||
| # - height and listheight are automatically calculated based on the number of options in the list or the number of lines in the text file. | ||
| # | ||
| # WHIPTAIL Box options: | ||
| # --msgbox <text> <height auto calculated> <width auto calculated> | ||
| # --yesno <text> <height> <width> (N/A) | ||
| # --infobox <text> <height> <width> (N/A) | ||
| # --inputbox <text> <height static> <width auto calculated> [init] | ||
| # --passwordbox <text> <height> <width> [init] (N/A) | ||
| # --textbox <file> <height auto calculated> <width static> | ||
| # --menu <text> <height auto calculated> <width auto calculated> <listheight auto calculated> [tag item] | ||
| # --checklist <text> <height auto calculated> <width auto calculated> <listheight auto calculated> [tag item status] | ||
| # --radiolist <text> <height auto calculated> <width auto calculated> <listheight auto calculated> [tag item status] | ||
| # --gauge <text> <height> <width> <percent> (N/A) | ||
| # | ||
|
|
||
| function whiptail_msgbox() { | ||
| local TITLE=$1 | ||
| local TEXT=$2 | ||
| local LEN | ||
| LEN=$(echo "$TEXT" | wc -l) | ||
| local HIGHT=$(( LEN + 7 )) | ||
| (( HIGHT > 30 )) && HIGHT=30 | ||
| local WIDTH=$(( ${#TITLE} + 16 )) | ||
| local WIDTH_ARRAY=( "$WIDTH" $(( ${#TEXT} + 4 )) ) | ||
| for i in "${WIDTH_ARRAY[@]}"; do | ||
| (( i > WIDTH )) && WIDTH=$i | ||
| done | ||
| (( WIDTH > 150 )) && WIDTH=150 | ||
|
|
||
| whiptail --backtitle "$APP_BACKTITLE" --title "$TITLE" --scrolltext --msgbox "$TEXT" "$HIGHT" "$WIDTH" 3>&1 1>&2 2>&3 | ||
| } | ||
|
|
||
| function whiptail_inputbox() { | ||
| local TITLE=$1 | ||
| local TEXT=$2 | ||
| local VALUE_INIT=$3 | ||
| local VALUE_INPUT | ||
| local HIGHT=10 | ||
| local WIDTH=$(( ${#TITLE} + 16 )) | ||
| local WIDTH_ARRAY=( "$WIDTH" $(( ${#TEXT} + 4 )) $(( ${#VALUE_INIT} + 8 )) ) | ||
| for i in "${WIDTH_ARRAY[@]}"; do | ||
| (( i > WIDTH )) && WIDTH=$i | ||
| done | ||
|
|
||
| if VALUE_INPUT=$(whiptail --backtitle "$APP_BACKTITLE" --title "$TITLE" --inputbox "\n$TEXT" \ | ||
| "$HIGHT" "$WIDTH" "$VALUE_INIT" 3>&1 1>&2 2>&3); then | ||
| echo "$VALUE_INPUT" | ||
| else | ||
| echo "$VALUE_INIT" | ||
| fi | ||
| } | ||
|
|
||
| function whiptail_textbox() { | ||
| local TITLE=$1 | ||
| local FILE=$2 | ||
| local LEN | ||
| LEN=$(wc -l < "$FILE") | ||
| local HIGHT=$(( LEN + 7 )) | ||
| (( HIGHT > 30 )) && HIGHT=30 | ||
| local WIDTH=150 | ||
|
|
||
| whiptail --backtitle "$APP_BACKTITLE" --title "$TITLE" --scrolltext --textbox "$FILE" "$HIGHT" "$WIDTH" 3>&1 1>&2 2>&3 | ||
| } | ||
|
|
||
| function whiptail_menu() { | ||
| local TITLE=$1 | ||
| local TEXT="\nSelect an option:" | ||
| local LEN=$(( ${#OPTIONS[@]} / 2 )) | ||
| local HIGHT=$(( LEN + 9 )) | ||
| local WIDTH=$(( ${#TITLE} + 16 )) | ||
| local WIDTH_OFFSET=5 | ||
| local CHOICE | ||
| local MAX_LEFT=0 | ||
| local MAX_RIGHT=0 | ||
| for ((i=0; i<${#OPTIONS[@]}; i+=2)); do | ||
| (( ${#OPTIONS[i]} > MAX_LEFT )) && MAX_LEFT=${#OPTIONS[i]} | ||
| (( ${#OPTIONS[$(( i+1 ))]} > MAX_RIGHT )) && MAX_RIGHT=${#OPTIONS[$(( i+1 ))]} | ||
| done | ||
| (( MAX_LEFT + MAX_RIGHT + WIDTH_OFFSET > WIDTH )) && WIDTH=$(( MAX_LEFT + MAX_RIGHT + WIDTH_OFFSET )) | ||
|
|
||
| if CHOICE=$(whiptail --backtitle "$APP_BACKTITLE" --title "$TITLE" --menu "$TEXT" \ | ||
| "$HIGHT" "$WIDTH" "$LEN" "${OPTIONS[@]}" 3>&1 1>&2 2>&3 || true); then | ||
| echo "$CHOICE" | ||
| fi | ||
| } | ||
|
|
||
| function whiptail_checklist() { | ||
| local TITLE=$1 | ||
| local TEXT=$2 | ||
| local -n LIST=$3 | ||
| local CHOICE | ||
| local OPTIONS=() | ||
| local WIDTH=$(( ${#TITLE} + 16 )) | ||
| local WIDTH_OFFSET=15 | ||
| local MAX_LEFT=0 | ||
| local MAX_RIGHT=0 | ||
|
|
||
| for ((i=0; i<${#LIST[@]}; i+=2)); do | ||
| local j=$(( i+1 )) | ||
| (( ${#LIST[i]} > MAX_LEFT )) && MAX_LEFT=${#LIST[i]} | ||
| (( ${#LIST[j]} > MAX_RIGHT )) && MAX_RIGHT=${#LIST[j]} | ||
| OPTIONS+=("${LIST[i]}" "${LIST[j]}" "OFF") | ||
| done | ||
| (( MAX_LEFT + MAX_RIGHT + WIDTH_OFFSET > WIDTH )) && WIDTH=$(( MAX_LEFT + MAX_RIGHT + WIDTH_OFFSET )) | ||
| local LEN=$(( ${#OPTIONS[@]} / 2 )) | ||
| (( LEN > 21 )) && LEN=21 | ||
| local HIGHT=$(( LEN + 9 )) | ||
|
|
||
| if CHOICE=$(whiptail --backtitle "$APP_BACKTITLE" --title "$TITLE" --scrolltext --checklist "$TEXT" \ | ||
| "$HIGHT" "$WIDTH" "$LEN" "${OPTIONS[@]}" 3>&1 1>&2 2>&3 | tr -d '"'); then | ||
| echo "$CHOICE" | ||
| fi | ||
| } | ||
|
|
||
| function whiptail_radiolist() { | ||
| local TITLE=$1 | ||
| local TEXT=$2 | ||
| local -n LIST=$3 | ||
| local CHOICE | ||
| local OPTIONS=() | ||
| local WIDTH=$(( ${#TITLE} + 16 )) | ||
| local WIDTH_OFFSET=15 | ||
| local MAX_LEFT=0 | ||
| local MAX_RIGHT=0 | ||
|
|
||
| for ((i=0; i<${#LIST[@]}; i+=2)); do | ||
| local j=$(( i+1 )) | ||
| (( ${#LIST[i]} > MAX_LEFT )) && MAX_LEFT=${#LIST[i]} | ||
| (( ${#LIST[j]} > MAX_RIGHT )) && MAX_RIGHT=${#LIST[j]} | ||
| OPTIONS+=("${LIST[i]}" "${LIST[j]}" "OFF") | ||
| done | ||
| (( MAX_LEFT + MAX_RIGHT + WIDTH_OFFSET > WIDTH )) && WIDTH=$(( MAX_LEFT + MAX_RIGHT + WIDTH_OFFSET )) | ||
| local LEN=$(( ${#OPTIONS[@]} / 2 )) | ||
| (( LEN > 21 )) && LEN=21 | ||
| local HIGHT=$(( LEN + 9 )) | ||
|
|
||
| if CHOICE=$(whiptail --backtitle "$APP_BACKTITLE" --title "$TITLE" --scrolltext --radiolist "$TEXT" \ | ||
| "$HIGHT" "$WIDTH" "$LEN" "${OPTIONS[@]}" 3>&1 1>&2 2>&3 | tr -d '"'); then | ||
| echo "$CHOICE" | ||
| fi | ||
| } | ||
|
heinemannj marked this conversation as resolved.
Outdated
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should not be part of this PR.
there is another PR open for this, and we'd rather like those changes be incorporated into our existing funcs, if even needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are partly wrong - I've opened a PR for
pve-lxc-system-admin.sh#1627
During the initial discussion on this PR I have only asked for a suitable possibility to add some new supporting functions ...
For the moment the refactoring of the
step-caLXC is much more important (separate PR is coming quickly) and for that reason thisstep-adminAdd-On will be handled by me with priority.If needed I can make separate PRs for the supporting functions, but for the moment from my perspection nothing is opened beside parts of this PR...
How to proceed???
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we won't just add new core things for a single script, and we will also not create even more scripts like admin-core.sh.
also those changes make not that much sense, as some of that code already exists in our functions and would be doubled code.
Yes seperate Pr for supporting funcs would be appreciated, but this would come with integrating them into our existing core and possible also directly applying to other scripts that may benefit from the new helper function
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
detect_osfunction:whitailis widely used in your framework - but every usage of whiptail is handmade ...resolve_ipfunction:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the whiptail is definitely something we have already talked about, but ultimately not yet tackled as basically every whiptail is a lot different.
So I think it would be nice if you could contribute the whiptail function as seperate PR.
Same for detect_os, but I think that can be incorporated into out core, as there are possibly already parts of that in core.
@MickLesk please correct me if I'm wrong. You know best about core.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@CrazyWolf13 and @MickLesk :
whiptailhelper-scripts: whiptail helper functions for dialog boxes #1760detect_osfunction - giving up - moved back to the step-admin add-onresolve_ipfunction - giving up - moved back to the step-admin add-on