Here is code I working on that scans the hestia/bin dir and captures data and creates a hestiacp.cheat file formatted for navi (with variables for input options).
#!/bin/bash
cheat_file=~/hestiacp.cheat
cd /usr/local/hestia/bin || exit
echo “% HestiaCP” > “$cheat_file”
for file in *; do
info=$(awk ‘/^# info:/ { sub("^# info: ", “”, $0); print $0; }’ “$file”)
options=$(awk ‘/^# options:/ { sub("^# options: ", “”, $0); print $0; }’ “$file”)
formatted_options=$(grep -oE ‘[[1][A-Z_]+[^]]’ <<< “$options”)
formatted_options=$(sed -E ‘s/([A-Z_]+)/<\L\1>/g’ <<< “$formatted_options”)
formatted_options=$(tr -s ’ ’ <<< “$formatted_options”)
formatted_options=$(tr -d ‘\n’ <<< “$formatted_options”)
echo “# $info” >> “$cheat_file”
echo “$file $formatted_options” >> “$cheat_file”
echo >> “$cheat_file”
done
It works almost perfect. Like 99% accurate.
Issues:
options that were in [ ] in the bash file are phrased without a space.
and
# change user nameservers
v-change-user-ns <user> <ns>1 <ns>2<ns>3<ns>4<ns>5<ns>6<ns>7<ns>8
it did not interpret this line right
# options: USER NS1 NS2 [NS3] [NS4] [NS5] [NS6] [NS7] [NS8]
# update system ip
v-update-sys-ip <none>
# options: NONE
It needs to ignore the use of NONE
# archive directory
v-add-fs-archive <user> <archive> <source> <source>.
# options: USER ARCHIVE SOURCE [SOURCE...]
I think this is more a hetis cli script issue with…
Can anyone fix the last few issues? I’ve got to my limit of my skills at this point. (I’ve only started learning how to write bash scripts less then a month. Figured its time to get better at it then just running basic commands) So please forgive me if the answer is something stupid easy.
I think if the last few things were fixed this would be a great help for the community. Or even useful if made part of hestia’s installer. When you install or upgrade a up to date cheatsheet in left for you to optionally use… Please tell me i’m not the only one who can’t remember all the CLI commands and has to look them up? with Navi and the way this formats you can select the command, fill in the option variables hit enter and done!
Here is repo
https://github.com/vontainment/hestiacp-cheat-sheet