mirror of
https://github.com/oSoWoSo/DistroHopper.git
synced 2024-08-14 22:46:53 +00:00
Big loop refactoring
This commit is contained in:
parent
95c3e6c228
commit
68e148b5fc
1 changed files with 489 additions and 487 deletions
378
dh
378
dh
|
@ -4,8 +4,14 @@
|
||||||
TEXTDOMAIN=distrohopper
|
TEXTDOMAIN=distrohopper
|
||||||
TEXTDOMAINDIR=/usr/share/locale
|
TEXTDOMAINDIR=/usr/share/locale
|
||||||
export "TEXTDOMAINDIR" "TEXTDOMAIN"
|
export "TEXTDOMAINDIR" "TEXTDOMAIN"
|
||||||
# bugs notice
|
|
||||||
function some_bugs() {
|
trap 'exit' SIGINT SIGTERM SIGQUIT
|
||||||
|
set -e
|
||||||
|
echo $"DistroHopper is running... Press Ctrl-Q anytime to exit."
|
||||||
|
|
||||||
|
while true
|
||||||
|
do
|
||||||
|
function bugs_notice_show() {
|
||||||
echo ""
|
echo ""
|
||||||
echo $"Done"
|
echo $"Done"
|
||||||
echo ""
|
echo ""
|
||||||
|
@ -17,9 +23,9 @@ function some_bugs() {
|
||||||
echo ""
|
echo ""
|
||||||
echo $"Wish you flawless distro hopping..."
|
echo $"Wish you flawless distro hopping..."
|
||||||
echo " zenobit"
|
echo " zenobit"
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_help() {
|
function help_show() {
|
||||||
echo "DistroHopper v. $version"
|
echo "DistroHopper v. $version"
|
||||||
echo "quickemu v. $("$portable_prefix"quickemu --version)"
|
echo "quickemu v. $("$portable_prefix"quickemu --version)"
|
||||||
printf $"\texample for First run from terminal: ./dh i && dh s g\n"
|
printf $"\texample for First run from terminal: ./dh i && dh s g\n"
|
||||||
|
@ -48,39 +54,38 @@ function show_help() {
|
||||||
echo $"Homepage: dh.osowoso.xyz"
|
echo $"Homepage: dh.osowoso.xyz"
|
||||||
echo $"Project hosted at: https://github.com/oSoWoSo/DistroHopper"
|
echo $"Project hosted at: https://github.com/oSoWoSo/DistroHopper"
|
||||||
echo $"Chat group on SimpleX: https://tinyurl.com/7hm4kcjx"
|
echo $"Chat group on SimpleX: https://tinyurl.com/7hm4kcjx"
|
||||||
}
|
}
|
||||||
|
|
||||||
function portable() {
|
function check_and_set_mode() {
|
||||||
[ -f "$DH_CONFIG" ] && mode_installed || mode_portable
|
[ -f "$DH_CONFIG" ] && work_in_choosed_dir || work_in_current_dir
|
||||||
}
|
}
|
||||||
|
|
||||||
function mode_portable() {
|
function work_in_current_dir() {
|
||||||
VMS_DIR="$(pwd)"
|
VMS_DIR="$(pwd)"
|
||||||
DH_CONFIG_DIR="$(pwd)"
|
DH_CONFIG_DIR="$(pwd)"
|
||||||
DH_ICON_DIR="$(pwd)/icons"
|
DH_ICON_DIR="$(pwd)/icons"
|
||||||
portable_prefix='./'
|
portable_prefix='./'
|
||||||
export "VMS_DIR" "DH_CONFIG_DIR" "DH_ICON_DIR" "TERMINAL" "replace" "portable_prefix"
|
export "VMS_DIR" "DH_CONFIG_DIR" "DH_ICON_DIR" "TERMINAL" "replace" "portable_prefix"
|
||||||
}
|
}
|
||||||
|
|
||||||
function mode_installed() {
|
function work_in_choosed_dir() {
|
||||||
# shellcheck source=distrohopper.conf
|
# shellcheck source=distrohopper.conf
|
||||||
source "$DH_CONFIG"
|
source "$DH_CONFIG"
|
||||||
portable_prefix=''
|
portable_prefix=''
|
||||||
export "portable_prefix"
|
export "portable_prefix"
|
||||||
}
|
}
|
||||||
# installation ---------------------------
|
|
||||||
function check_gui_dependencies() {
|
# installation ---------------------------
|
||||||
|
|
||||||
|
function gui_dependencies_check() {
|
||||||
[ -f "$PATH_PREFIX/yad" ] || echo $"Missing yad!"
|
[ -f "$PATH_PREFIX/yad" ] || echo $"Missing yad!"
|
||||||
}
|
}
|
||||||
trap 'exit' SIGINT SIGTERM SIGQUIT
|
|
||||||
set -e
|
|
||||||
echo $"DistroHopper is running... Press Ctrl-Q anytime to exit."
|
|
||||||
|
|
||||||
function check_tui_dependencies() {
|
function tui_dependencies_check() {
|
||||||
[ -f "$PATH_PREFIX/fzf" ] || echo $"Missing fzf!"
|
[ -f "$PATH_PREFIX/fzf" ] || echo $"Missing fzf!"
|
||||||
}
|
}
|
||||||
|
|
||||||
function set_variables() {
|
function variables_set() {
|
||||||
# DEBUG mod
|
# DEBUG mod
|
||||||
#bash -x ./dh 2>&1 | tee output.log
|
#bash -x ./dh 2>&1 | tee output.log
|
||||||
#progname="${progname:="${0##*/}"}"
|
#progname="${progname:="${0##*/}"}"
|
||||||
|
@ -95,13 +100,13 @@ function set_variables() {
|
||||||
TERMINAL="sakura"
|
TERMINAL="sakura"
|
||||||
replace='"!"'
|
replace='"!"'
|
||||||
export "DH_CONFIG_DIR" "DH_CONFIG" "replace" "DH_ICON_DIR" "PATH_PREFIX" "TMP_DIR" "TERMINAL"
|
export "DH_CONFIG_DIR" "DH_CONFIG" "replace" "DH_ICON_DIR" "PATH_PREFIX" "TMP_DIR" "TERMINAL"
|
||||||
portable
|
check_and_set_mode
|
||||||
# Set traps to catch the signals and exit gracefully
|
# Set traps to catch the signals and exit gracefully
|
||||||
trap "exit" INT
|
trap "exit" INT
|
||||||
trap "exit" EXIT
|
trap "exit" EXIT
|
||||||
}
|
}
|
||||||
|
|
||||||
function create_desktop_entry() {
|
function desktop_entry_create() {
|
||||||
cat <<EOF > ${DESKTOP_FILE}
|
cat <<EOF > ${DESKTOP_FILE}
|
||||||
[Desktop Entry]
|
[Desktop Entry]
|
||||||
Version=$version
|
Version=$version
|
||||||
|
@ -120,58 +125,44 @@ MimeType=$mime
|
||||||
Keywords=$keyword
|
Keywords=$keyword
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
function create_structure() {
|
function directory_structure_create() {
|
||||||
source distrohopper.conf
|
source distrohopper.conf
|
||||||
echo $"creating config dir..."
|
echo $"creating config dir..."
|
||||||
mkdir -p "$DH_CONFIG_DIR"
|
mkdir -p "$DH_CONFIG_DIR"
|
||||||
echo $"creating icons dir as root..."
|
echo $"creating icons dir as root..."
|
||||||
mkdir -p "$DH_ICON_DIR" >/dev/null 2>&1 || sudo mkdir -p "$DH_ICON_DIR"
|
mkdir -p "$DH_ICON_DIR" >/dev/null 2>&1 || sudo mkdir -p "$DH_ICON_DIR"
|
||||||
}
|
}
|
||||||
|
|
||||||
function dh_desktop_entry() {
|
function desktop_entry_distrohopper() {
|
||||||
echo $"Do you want DistroHopper to run in the terminal? (y/n)"
|
echo $"Do you want DistroHopper to run in the terminal? (y/n)"
|
||||||
run_in_terminal
|
run_in_terminal
|
||||||
|
DESKTOP_FILE="${TMP_DIR}/dh.desktop"
|
||||||
|
type='Application'
|
||||||
|
name='DistroHopper'
|
||||||
|
comment='Quickly download, create and run VM of any#TODO operating system.'
|
||||||
|
version='0.77b'
|
||||||
|
execmd="sh -c 'cd ${VMS_DIR} && dh g'"
|
||||||
if [ "$interminal" == "yes" ]; then
|
if [ "$interminal" == "yes" ]; then
|
||||||
cat <<EOF > ${TMP_DIR}/dh.desktop
|
terminal='true'
|
||||||
[Desktop Entry]
|
|
||||||
Type=Application
|
|
||||||
Name=DistroHopper
|
|
||||||
Description=Quickly download, create and run VM of any#TODO operating system.
|
|
||||||
version=0.77b
|
|
||||||
Terminal=true
|
|
||||||
Exec=sh -c 'cd ${VMS_DIR} && dh g'
|
|
||||||
Icon=/home/zen/git/distrohopper/icons/hop
|
|
||||||
Categories=System;Virtualization;
|
|
||||||
|
|
||||||
EOF
|
|
||||||
else
|
|
||||||
cat <<EOF > ${TMP_DIR}/dh.desktop
|
|
||||||
[Desktop Entry]
|
|
||||||
Type=Application
|
|
||||||
Name=DistroHopper
|
|
||||||
Description=Quickly download, create and run VM of any#TODO operating system.
|
|
||||||
version=0.77b
|
|
||||||
Exec=sh -c 'cd ${VMS_DIR} && dh g'
|
|
||||||
Icon=/home/zen/git/distrohopper/icons/hop
|
|
||||||
Categories=System;Virtualization;
|
|
||||||
|
|
||||||
EOF
|
|
||||||
fi
|
fi
|
||||||
|
icon='hop'
|
||||||
|
categories='System;Virtualization;'
|
||||||
|
desktop_entry_create
|
||||||
sudo cp ${TMP_DIR}/dh.desktop /usr/share/applications/
|
sudo cp ${TMP_DIR}/dh.desktop /usr/share/applications/
|
||||||
}
|
}
|
||||||
|
|
||||||
function set_dir() {
|
function virtual_machines_directory_choose() {
|
||||||
NEWDIR="$(yad --width=900 --height=900 --file --directory --title="Where to save VMs?")"
|
NEWDIR="$(yad --width=900 --height=900 --file --directory --title="Where to save VMs?")"
|
||||||
VMS_DIR="$NEWDIR"
|
VMS_DIR="$NEWDIR"
|
||||||
echo "VMS_DIR=\"$VMS_DIR\"
|
echo "VMS_DIR=\"$VMS_DIR\"
|
||||||
export \"VMS_DIR\"" >> "$DH_CONFIG"
|
export \"VMS_DIR\"" >> "$DH_CONFIG"
|
||||||
export "VMS_DIR"
|
export "VMS_DIR"
|
||||||
}
|
}
|
||||||
|
|
||||||
function install_prereq() {
|
function dependencies_install() {
|
||||||
# Find the current distribution and install dependecies
|
# Find the current distribution and install dependecies
|
||||||
if [ -f /etc/os-release ]; then
|
if [ -f /etc/os-release ]; then
|
||||||
if grep -q arch /etc/os-release; then
|
if grep -q arch /etc/os-release; then
|
||||||
sudo pacman -S cdrtools coreutils edk2-ovmf grep jq procps python3 qemu-full sed socat spice-gtk swtpm usbutils util-linux wget xdg-user-dirs xorg-xrandr zsync getext yad fzf
|
sudo pacman -S cdrtools coreutils edk2-ovmf grep jq procps python3 qemu-full sed socat spice-gtk swtpm usbutils util-linux wget xdg-user-dirs xorg-xrandr zsync getext yad fzf
|
||||||
|
@ -196,9 +187,9 @@ function install_prereq() {
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function install_dh() {
|
function distrohopper_install() {
|
||||||
cp dh quickget quickemu macrecovery windowskey "$PATH_PREFIX" >/dev/null 2>&1 || sudo cp dh quickget quickemu macrecovery windowskey "$PATH_PREFIX"
|
cp dh quickget quickemu macrecovery windowskey "$PATH_PREFIX" >/dev/null 2>&1 || sudo cp dh quickget quickemu macrecovery windowskey "$PATH_PREFIX"
|
||||||
# quickget also to config directory for adding new distros...
|
# quickget also to config directory for adding new distros...
|
||||||
cp quickget "$DH_CONFIG_DIR/"
|
cp quickget "$DH_CONFIG_DIR/"
|
||||||
|
@ -208,41 +199,42 @@ function install_dh() {
|
||||||
cp -r ready "$DH_CONFIG_DIR/"
|
cp -r ready "$DH_CONFIG_DIR/"
|
||||||
cp -r supported "$DH_CONFIG_DIR/"
|
cp -r supported "$DH_CONFIG_DIR/"
|
||||||
cp -r locale "$DH_CONFIG_DIR/"
|
cp -r locale "$DH_CONFIG_DIR/"
|
||||||
}
|
}
|
||||||
|
|
||||||
function install_process() {
|
function installation_process() {
|
||||||
check_tui_dependencies
|
tui_dependencies_check
|
||||||
check_gui_dependencies
|
gui_dependencies_check
|
||||||
#check_quickemu_dependencies
|
#check_quickemu_dependencies
|
||||||
echo $"Creating directory structure..." \
|
echo $"Creating directory structure..." \
|
||||||
&& create_structure \
|
&& directory_structure_create \
|
||||||
&& echo $"Setting up directory..." \
|
&& echo $"Setting up directory..." \
|
||||||
&& set_dir \
|
&& virtual_machines_directory_choose \
|
||||||
&& echo $"Installing needed..." \
|
&& echo $"Installing needed..." \
|
||||||
&& install_prereq \
|
&& dependencies_install \
|
||||||
&& echo $"Installing DistroHopper to bin..." \
|
&& echo $"Installing DistroHopper to bin..." \
|
||||||
&& install_dh \
|
&& distrohopper_install \
|
||||||
&& echo $"Copying desktop entry..." \
|
&& echo $"Copying desktop entry..." \
|
||||||
&& dh_desktop_entry
|
&& desktop_entry_distrohopper
|
||||||
}
|
}
|
||||||
# basic -----------------------------------
|
|
||||||
|
|
||||||
function run_in_terminal() {
|
# basic -----------------------------------
|
||||||
|
|
||||||
|
function run_in_terminal() {
|
||||||
read -r response
|
read -r response
|
||||||
if [[ "$response" =~ ^[YyAa]$ ]]; then
|
if [[ "$response" =~ ^[YyAa]$ ]]; then
|
||||||
interminal="yes"
|
interminal="yes"
|
||||||
else
|
else
|
||||||
interminal="no"
|
interminal="no"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function renew_ready() {
|
function virtual_machines_update_ready() {
|
||||||
cd "$VMS_DIR" || exit 1
|
cd "$VMS_DIR" || exit 1
|
||||||
# for files in "$VMS_DIR"/*; do
|
# for files in "$VMS_DIR"/*; do
|
||||||
# if [ ! -e *.conf ]; then
|
# if [ ! -e *.conf ]; then
|
||||||
# echo $"No .conf files found"
|
# echo $"No .conf files found"
|
||||||
# return
|
# return
|
||||||
# fi
|
# fi
|
||||||
for vm_conf in *.conf; do
|
for vm_conf in *.conf; do
|
||||||
if [ "$vm_conf" == "distrohopper.conf" ]; then
|
if [ "$vm_conf" == "distrohopper.conf" ]; then
|
||||||
continue # skip processing distrohopper.conf
|
continue # skip processing distrohopper.conf
|
||||||
|
@ -258,20 +250,19 @@ function renew_ready() {
|
||||||
elif [ -z "$icon_file" ]; then
|
elif [ -z "$icon_file" ]; then
|
||||||
icon_file="$DH_ICON_DIR/tux.svg"
|
icon_file="$DH_ICON_DIR/tux.svg"
|
||||||
fi
|
fi
|
||||||
# content of desktop files (ready to run VMs)
|
DESKTOP_FILE="$DH_CONFIG_DIR/ready/$vm_desktop.desktop"
|
||||||
cat <<EOF > "$DH_CONFIG_DIR"/ready/"$vm_desktop".desktop
|
type='Application'
|
||||||
[Desktop Entry]
|
name="$vm_desktop"
|
||||||
Type=Application
|
comment='Quickly download, create and run VM of any#TODO operating system.'
|
||||||
Name=$vm_desktop
|
version='0.77b'
|
||||||
Exec=sh -c 'cd ${VMS_DIR} && ${portable_prefix}quickemu -vm ${vm_conf}'
|
execmd="sh -c 'cd ${VMS_DIR} && ${portable_prefix}quickemu -vm ${vm_conf}'"
|
||||||
Icon=$icon_file
|
icon="$icon_file"
|
||||||
Categories=System;Virtualization;
|
categories='System;Virtualization;'
|
||||||
|
desktop_entry_create
|
||||||
EOF
|
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
function renew_supported() {
|
function virtual_machines_update_supported() {
|
||||||
echo $"Do you want quickget to show outputs in the terminal? (y/n)"
|
echo $"Do you want quickget to show outputs in the terminal? (y/n)"
|
||||||
run_in_terminal
|
run_in_terminal
|
||||||
# get supported VMs
|
# get supported VMs
|
||||||
|
@ -291,45 +282,54 @@ function renew_supported() {
|
||||||
echo $"Creating $vm_desktop desktop entry..."
|
echo $"Creating $vm_desktop desktop entry..."
|
||||||
echo ""
|
echo ""
|
||||||
# Check if there are editions
|
# Check if there are editions
|
||||||
|
DESKTOP_FILE="$DH_CONFIG_DIR/supported/$vm_desktop.desktop"
|
||||||
|
type='Application'
|
||||||
|
name="$get_name"
|
||||||
|
releases=$releases
|
||||||
|
replace=$replace
|
||||||
if [ -z "$editions" ]; then
|
if [ -z "$editions" ]; then
|
||||||
cat <<EOF > "$DH_CONFIG_DIR"/supported/"$vm_desktop".desktop
|
execmd="sh -c 'cd $VMS_DIR && yad --form --field=\"Release:CB\" \"${releases// /$replace}\" | cut -d\'|\' -f1 | xargs -I{} sh -c \"${portable_prefix}quickget $get_name {}\"'"
|
||||||
[Desktop Entry]
|
elif [ "$interminal" == "yes" ]; then
|
||||||
Type=Application
|
terminal='true'
|
||||||
Name=$get_name
|
|
||||||
releases=$releases
|
|
||||||
replace=$replace
|
|
||||||
Exec=sh -c 'cd "$VMS_DIR" && yad --form --field="Release:CB" "${releases// /$replace}" | cut -d"|" -f1 | xargs -I{} sh -c "${portable_prefix}quickget $get_name {}"'
|
|
||||||
Icon=$icon_file
|
|
||||||
Categories=System;Virtualization;
|
|
||||||
|
|
||||||
EOF
|
|
||||||
else
|
else
|
||||||
cat <<EOF > "$DH_CONFIG_DIR"/supported/"$vm_desktop".desktop
|
editions=$editions
|
||||||
[Desktop Entry]
|
execcmd="sh -c 'cd $VMS_DIR && yad --form --separator=\" \" --field=\"Release:CB\" \"${releases// /$replace}\" --field=\"Edition:CB\" \"${editions// /$replace}\" | xargs -I{} sh -c \"${portable_prefix}quickget $get_name {}\"'"
|
||||||
Type=Application
|
|
||||||
Name=$get_name
|
|
||||||
releases=$releases
|
|
||||||
editions=$editions
|
|
||||||
replace=$replace
|
|
||||||
Exec=sh -c 'cd $VMS_DIR && yad --form --separator=" " --field="Release:CB" "${releases// /$replace}" --field="Edition:CB" "${editions// /$replace}" | xargs -I{} sh -c "${portable_prefix}quickget $get_name {}"'
|
|
||||||
Icon=$icon_file
|
|
||||||
Categories=System;Virtualization;
|
|
||||||
|
|
||||||
EOF
|
|
||||||
fi
|
fi
|
||||||
done < "$DH_CONFIG_DIR"/supported.md
|
icon='hop'
|
||||||
}
|
categories='System;Virtualization;'
|
||||||
|
|
||||||
function run_gui() {
|
desktop_entry_create
|
||||||
check_gui_dependencies
|
done < "$DH_CONFIG_DIR"/supported.md
|
||||||
|
}
|
||||||
|
|
||||||
|
function distrohopper_run_gui() {
|
||||||
|
gui_dependencies_check
|
||||||
key=$((RANDOM % 9000 + 1000))
|
key=$((RANDOM % 9000 + 1000))
|
||||||
yad --plug="$key" --tabnum=1 --monitor --icons --listen --read-dir="$DH_CONFIG_DIR"/ready --sort-by-name --no-buttons --borders=0 --icon-size=46 --item-width=76 &
|
yad --plug="$key" --tabnum=1 --monitor --icons --listen --read-dir="$DH_CONFIG_DIR"/ready --sort-by-name --no-buttons --borders=0 --icon-size=46 --item-width=76 &
|
||||||
yad --plug="$key" --tabnum=2 --monitor --icons --listen --read-dir="$DH_CONFIG_DIR"/supported --sort-by-name --no-buttons --borders=0 --icon-size=46 --item-width=76 &
|
yad --plug="$key" --tabnum=2 --monitor --icons --listen --read-dir="$DH_CONFIG_DIR"/supported --sort-by-name --no-buttons --borders=0 --icon-size=46 --item-width=76 &
|
||||||
yad --dynamic --notebook --key="$key" --monitor --listen --window-icon="$DH_ICON_DIR"/hop.svg --width=900 --height=900 --title="DistroHopper" --tab="run VM" --tab="download VM"
|
yad --dynamic --notebook --key="$key" --monitor --listen --window-icon="$DH_ICON_DIR"/hop.svg --width=900 --height=900 --title="DistroHopper" --tab="run VM" --tab="download VM"
|
||||||
}
|
}
|
||||||
|
|
||||||
function run_tui() {
|
function distrohopper_run_tui() {
|
||||||
check_tui_dependencies
|
tui_dependencies_check
|
||||||
|
tui_run
|
||||||
|
if [ "$todo" = "create" ]; then
|
||||||
|
virtual_machine_create
|
||||||
|
tui_windows
|
||||||
|
tui_get_releases_and_editions
|
||||||
|
tui_get_releases
|
||||||
|
if [ "$(echo "$choices" | wc -l)" = 1 ]; then
|
||||||
|
tui_downloading
|
||||||
|
else
|
||||||
|
tui_get_editions
|
||||||
|
tui_downloading_with_edition
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
virtual_machine_choose_to_run
|
||||||
|
virtual_machine_run
|
||||||
|
}
|
||||||
|
|
||||||
|
tui_run() {
|
||||||
cd "$VMS_DIR" || exit 1
|
cd "$VMS_DIR" || exit 1
|
||||||
vms=(*.conf)
|
vms=(*.conf)
|
||||||
printf $" Prepared VMs:\n-------------\n\n"
|
printf $" Prepared VMs:\n-------------\n\n"
|
||||||
|
@ -350,17 +350,41 @@ function run_tui() {
|
||||||
todo="create"
|
todo="create"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
# If the user chose to create a new VM
|
virtual_machine_create() {
|
||||||
if [ "$todo" = "create" ]; then
|
|
||||||
os=$("$portable_prefix"quickget | sed 1d | cut -d':' -f2 | grep -o '[^ ]*' | fzf --cycle --header='Choose OS to download
|
os=$("$portable_prefix"quickget | sed 1d | cut -d':' -f2 | grep -o '[^ ]*' | fzf --cycle --header='Choose OS to download
|
||||||
or CTRL-c or ESC to quit')
|
or CTRL-c or ESC to quit')
|
||||||
|
}
|
||||||
|
|
||||||
# If the OS is Windows
|
tui_get_releases_and_editions() {
|
||||||
|
choices=$("$portable_prefix"quickget "$os" | sed 1d)
|
||||||
|
}
|
||||||
|
|
||||||
|
tui_get_releases() {
|
||||||
|
release=$(echo "$choices" | grep 'Releases' | cut -d':' -f2 | grep -o '[^ ]*' | fzf --cycle --header='Choose Release
|
||||||
|
or CTRL-c or ESC to quit')
|
||||||
|
}
|
||||||
|
|
||||||
|
tui_get_editions() {
|
||||||
|
edition=$(echo "$choices" | grep 'Editions' | cut -d':' -f2 | grep -o '[^ ]*' | fzf --cycle --header='Choose Edition
|
||||||
|
or CTRL-c or ESC to quit')
|
||||||
|
}
|
||||||
|
|
||||||
|
tui_downloading() {
|
||||||
|
printf $"\n Trying to download %s %s...\n\n" "$os" "$release"
|
||||||
|
"$portable_prefix"quickget "$os" "$release"
|
||||||
|
}
|
||||||
|
|
||||||
|
tui_downloading_with_edition() {
|
||||||
|
printf $"\n Trying to download %s %s %s...\n\n" "$os" "$release" "$edition"
|
||||||
|
"$portable_prefix"quickget "$os" "$release" "$edition"
|
||||||
|
}
|
||||||
|
|
||||||
|
tui_windows() {
|
||||||
if [ "$os" = windows ]; then
|
if [ "$os" = windows ]; then
|
||||||
answer=$(echo "Default English
|
answer=$(echo "Default English
|
||||||
Choose other language" | fzf --cycle)
|
Choose other language" | fzf --cycle)
|
||||||
|
|
||||||
# If the user wants another windows language
|
# If the user wants another windows language
|
||||||
if [ "$answer" = "Choose other language" ]; then
|
if [ "$answer" = "Choose other language" ]; then
|
||||||
wrelease=$(echo "8
|
wrelease=$(echo "8
|
||||||
|
@ -379,53 +403,28 @@ Choose other language" | fzf --cycle)
|
||||||
"$portable_prefix"quickget "windows" "$wrelease" "$wlang"
|
"$portable_prefix"quickget "windows" "$wrelease" "$wlang"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Get the release and edition to download, if necessary
|
virtual_machine_choose_to_run() {
|
||||||
choices=$("$portable_prefix"quickget "$os" | sed 1d)
|
choosed=$(echo "$(ls ***.conf 2>/dev/null | sed 's/\.conf$//')" | fzf --cycle --header='Choose VM to run
|
||||||
|
|
||||||
if [ "$(echo "$choices" | wc -l)" = 1 ]; then
|
|
||||||
|
|
||||||
# get release
|
|
||||||
release=$(echo "$choices" | grep 'Releases' | cut -d':' -f2 | grep -o '[^ ]*' | fzf --cycle --header='Choose Release
|
|
||||||
or CTRL-c or ESC to quit')
|
or CTRL-c or ESC to quit')
|
||||||
|
}
|
||||||
|
|
||||||
# downloading
|
virtual_machine_run() {
|
||||||
printf $"\n Trying to download %s %s...\n\n" "$os" "$release"
|
|
||||||
"$portable_prefix"quickget "$os" "$release"
|
|
||||||
else
|
|
||||||
|
|
||||||
# get release
|
|
||||||
release=$(echo "$choices" | grep 'Releases' | cut -d':' -f2 | grep -o '[^ ]*' | fzf --cycle --header='Choose Release
|
|
||||||
or CTRL-c or ESC to quit')
|
|
||||||
|
|
||||||
# get edition
|
|
||||||
edition=$(echo "$choices" | grep 'Editions' | cut -d':' -f2 | grep -o '[^ ]*' | fzf --cycle --header='Choose Edition
|
|
||||||
or CTRL-c or ESC to quit')
|
|
||||||
|
|
||||||
# downloading
|
|
||||||
printf $"\n Trying to download %s %s %s...\n\n" "$os" "$release" "$edition"
|
|
||||||
"$portable_prefix"quickget "$os" "$release" "$edition"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# choose VM to run
|
|
||||||
choosed=$(echo "$(ls ./***.conf 2>/dev/null | sed 's/\.conf$//')" | fzf --cycle --header='Choose VM to run
|
|
||||||
or CTRL-c or ESC to quit')
|
|
||||||
|
|
||||||
# Run choosed VM
|
|
||||||
printf $"\n Starting %s...\n\n" "$choosed"
|
printf $"\n Starting %s...\n\n" "$choosed"
|
||||||
"$portable_prefix"quickemu -vm "$choosed.conf"
|
"$portable_prefix"quickemu -vm "$choosed.conf"
|
||||||
fi
|
}
|
||||||
}
|
|
||||||
|
|
||||||
# more
|
# more
|
||||||
function isos_to_dir() {
|
|
||||||
|
function isos_copy_to_dir() {
|
||||||
yad --width=900 --height=900 --file --directory > target
|
yad --width=900 --height=900 --file --directory > target
|
||||||
cd "$VMS_DIR" || exit 1
|
cd "$VMS_DIR" || exit 1
|
||||||
# shellcheck disable=2154
|
# shellcheck disable=2154
|
||||||
cp ./*glob*/*.iso "$target"
|
cp ./*glob*/*.iso "$target"
|
||||||
}
|
}
|
||||||
# shellcheck disable=2086
|
# shellcheck disable=2086
|
||||||
function add_distro() {
|
function add_distro() {
|
||||||
yad --form --field="Pretty name" "" --field="Name" "" --field="Releases" "" --field="Editions" "" --field="URL" "" --field="ISO" "" --field="Checksum file" "" > ${TMP_DIR}/template.tmp
|
yad --form --field="Pretty name" "" --field="Name" "" --field="Releases" "" --field="Editions" "" --field="URL" "" --field="ISO" "" --field="Checksum file" "" > ${TMP_DIR}/template.tmp
|
||||||
PRETTY_NAME="$(cat ${TMP_DIR}/template.tmp | cut -d'|' -f1)"
|
PRETTY_NAME="$(cat ${TMP_DIR}/template.tmp | cut -d'|' -f1)"
|
||||||
NAME="$(cat ${TMP_DIR}/template.tmp | cut -d'|' -f2)"
|
NAME="$(cat ${TMP_DIR}/template.tmp | cut -d'|' -f2)"
|
||||||
|
@ -468,9 +467,9 @@ function get_$NAME() {
|
||||||
EOF
|
EOF
|
||||||
echo "Done"
|
echo "Done"
|
||||||
meld "${TMP_DIR}"/template.tmp "$DH_CONFIG_DIR"/quickget
|
meld "${TMP_DIR}"/template.tmp "$DH_CONFIG_DIR"/quickget
|
||||||
}
|
}
|
||||||
|
|
||||||
function sort_functions() {
|
function sort_functions() {
|
||||||
#TODO
|
#TODO
|
||||||
# Get the name of the script from the command line argument
|
# Get the name of the script from the command line argument
|
||||||
script_name=$1
|
script_name=$1
|
||||||
|
@ -484,9 +483,9 @@ function sort_functions() {
|
||||||
# Print the function definition to stdout
|
# Print the function definition to stdout
|
||||||
grep -A "$(wc -l < "$script_name")" -w "function $function_name" "$script_name"
|
grep -A "$(wc -l < "$script_name")" -w "function $function_name" "$script_name"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
function translate() {
|
function translate() {
|
||||||
echo $"Which language change? (en/cs)"
|
echo $"Which language change? (en/cs)"
|
||||||
echo $"If you want create new one, insert two digit language code..."
|
echo $"If you want create new one, insert two digit language code..."
|
||||||
read lang
|
read lang
|
||||||
|
@ -503,56 +502,57 @@ function translate() {
|
||||||
echo $"Copying translation to '/usr/share/local'..."
|
echo $"Copying translation to '/usr/share/local'..."
|
||||||
sudo cp "$DH_CONFIG_DIR"/locale/distrohopper-"$lang".mo /usr/share/locale/"$lang"/LC_MESSAGES/distrohopper.mo
|
sudo cp "$DH_CONFIG_DIR"/locale/distrohopper-"$lang".mo /usr/share/locale/"$lang"/LC_MESSAGES/distrohopper.mo
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# run --------------------------------------
|
# run --------------------------------------
|
||||||
set_variables
|
|
||||||
|
|
||||||
if [[ $# -eq 0 ]]; then
|
variables_set
|
||||||
|
|
||||||
|
if [[ $# -eq 0 ]]; then
|
||||||
printf $"No argumet provided!\n\n"
|
printf $"No argumet provided!\n\n"
|
||||||
show_help
|
help_show
|
||||||
fi
|
fi
|
||||||
|
|
||||||
while [[ $# -gt 0 ]]
|
while [[ $# -gt 0 ]]
|
||||||
do
|
do
|
||||||
key="$1"
|
key="$1"
|
||||||
case $key in
|
case $key in
|
||||||
h|help)
|
h|help)
|
||||||
show_help
|
help_show
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
d|dir)
|
d|dir)
|
||||||
set_dir
|
virtual_machines_directory_choose
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
i|install)
|
i|install)
|
||||||
echo $"Starting installation..."
|
echo $"Starting installation..."
|
||||||
install_process
|
installation_process
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
m|mode)
|
m|mode)
|
||||||
echo $"Switching to portable mode!"
|
echo $"Switching to portable mode!"
|
||||||
mode_portable
|
work_in_current_dir
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
s|supported)
|
s|supported)
|
||||||
echo $"Updating supported VMs..."
|
echo $"Updating supported VMs..."
|
||||||
renew_supported
|
virtual_machines_update_supported
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
r|ready)
|
r|ready)
|
||||||
echo $"Updating ready VMs..."
|
echo $"Updating ready VMs..."
|
||||||
renew_ready
|
virtual_machines_update_ready
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
t|tui)
|
t|tui)
|
||||||
echo $"Running DistroHopper TUI..."
|
echo $"Running DistroHopper TUI..."
|
||||||
run_tui
|
distrohopper_run_tui
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
g|gui)
|
g|gui)
|
||||||
echo $"Starting DistroHopper GUI..."
|
echo $"Starting DistroHopper GUI..."
|
||||||
run_gui
|
distrohopper_run_gui
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
a|add)
|
a|add)
|
||||||
|
@ -572,7 +572,7 @@ do
|
||||||
;;
|
;;
|
||||||
c|copy)
|
c|copy)
|
||||||
echo $"Copying ISOs to dir. It will take some time..."
|
echo $"Copying ISOs to dir. It will take some time..."
|
||||||
isos_to_dir
|
isos_copy_to_dir
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
l|language)
|
l|language)
|
||||||
|
@ -580,18 +580,20 @@ do
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
z)
|
z)
|
||||||
WIP
|
run_tui_new
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo $"Invalid option: $1"
|
echo $"Invalid option: $1"
|
||||||
echo ""
|
echo ""
|
||||||
show_help
|
help_show
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
bugs_notice_show
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
||||||
some_bugs
|
|
||||||
|
|
||||||
exit 0
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue