2023-03-27 05:38:39 +00:00
|
|
|
#!/usr/bin/bash
|
|
|
|
# shellcheck disable=1078,1079,1091,2027,2034
|
|
|
|
|
|
|
|
TEXTDOMAIN=distrohopper
|
|
|
|
TEXTDOMAINDIR=/usr/share/locale
|
|
|
|
export "TEXTDOMAINDIR" "TEXTDOMAIN"
|
2023-03-23 20:21:46 +00:00
|
|
|
# bugs notice
|
2023-03-26 19:31:30 +00:00
|
|
|
function some_bugs() {
|
2023-03-28 00:39:56 +00:00
|
|
|
echo ""
|
2023-03-27 00:41:08 +00:00
|
|
|
echo $"Done"
|
2023-03-28 00:39:56 +00:00
|
|
|
echo ""
|
2023-03-27 00:41:08 +00:00
|
|
|
echo $"PS: You saw some bugs?"
|
|
|
|
echo $"Could you please provide feedback?"
|
|
|
|
echo $"How do you like DistroHopper?"
|
|
|
|
echo $"What can be improved, added, changed?"
|
|
|
|
echo $" Let me know..."
|
2023-03-28 00:39:56 +00:00
|
|
|
echo ""
|
|
|
|
echo $"Wish you flawless distro hopping..."
|
|
|
|
echo " zenobit"
|
2023-03-24 04:44:51 +00:00
|
|
|
}
|
|
|
|
|
2023-03-26 19:32:45 +00:00
|
|
|
function show_help() {
|
2023-03-27 23:38:11 +00:00
|
|
|
echo "DistroHopper v. $version"
|
|
|
|
echo "quickemu v. $("$prefix"quickemu --version)"
|
2023-03-29 22:00:01 +00:00
|
|
|
printf $"\texample for First run from terminal: ./dh i && dh s g\n"
|
2023-03-27 05:38:39 +00:00
|
|
|
echo $"Possible arguments:"
|
2023-03-29 21:33:30 +00:00
|
|
|
printf $"\th\thelp\t\t\tShow this help and exit\n"
|
2023-03-27 05:38:39 +00:00
|
|
|
echo "---------------------------------------------------------"
|
2023-03-29 21:33:30 +00:00
|
|
|
printf $"\td\tdir\t\t\tSet default directory where VMs are stored\n"
|
|
|
|
printf $"\ti\tinstall\t\t\tInstall DistroHopper\n"
|
2023-03-27 05:38:39 +00:00
|
|
|
echo "---------------------------------------------------------"
|
2023-03-29 21:33:30 +00:00
|
|
|
printf $"\tm\tmode\t\t\tPortable mode\n"
|
2023-03-27 05:38:39 +00:00
|
|
|
echo "---------------------------------------------------------"
|
2023-03-29 21:33:30 +00:00
|
|
|
printf $"\ts\tsupported\t\tUpdate supported VMs\n"
|
|
|
|
printf $"\tr\tready\t\t\tUpdate ready to run VMs\n"
|
2023-03-27 05:38:39 +00:00
|
|
|
echo "---------------------------------------------------------"
|
2023-03-29 21:33:30 +00:00
|
|
|
printf $"\tt\ttui\t\t\tRun TUI\n"
|
|
|
|
printf $"\tg\tgui\t\t\tRun GUI\n"
|
2023-03-27 05:38:39 +00:00
|
|
|
echo "---------------------------------------------------------"
|
2023-03-29 21:33:30 +00:00
|
|
|
printf $"\ta\tadd\t\t\tAdd new distro to quickget\n"
|
|
|
|
printf $"\tf\tfunctions\t\tSort functions in quickget\n"
|
|
|
|
printf $"\tp\tpush\t\t\tPush changed quickget to quickemu project #todo\n"
|
2023-03-27 05:38:39 +00:00
|
|
|
echo "---------------------------------------------------------"
|
2023-03-29 21:33:30 +00:00
|
|
|
printf $"\tc\tcopy\t\t\tCopy all ISOs to target dir (for Ventoy)\n"
|
2023-03-27 05:38:39 +00:00
|
|
|
echo "---------------------------------------------------------"
|
2023-03-29 21:33:30 +00:00
|
|
|
printf $"\tl\tlanguage\t\tTranslate DistroHopper\n"
|
2023-03-27 05:38:39 +00:00
|
|
|
echo "---------------------------------------------------------"
|
2023-03-27 00:41:08 +00:00
|
|
|
echo $"Homepage: dh.osowoso.xyz"
|
|
|
|
echo $"Project hosted at: https://github.com/oSoWoSo/DistroHopper"
|
|
|
|
echo $"Chat group on SimpleX: https://tinyurl.com/7hm4kcjx"
|
2023-03-23 20:21:46 +00:00
|
|
|
}
|
|
|
|
|
2023-03-26 19:32:45 +00:00
|
|
|
function portable() {
|
2023-03-24 05:57:02 +00:00
|
|
|
[ -f "$DH_CONFIG" ] && mode_installed || mode_portable
|
|
|
|
}
|
|
|
|
|
2023-03-26 19:32:45 +00:00
|
|
|
function mode_portable() {
|
2023-03-24 05:57:02 +00:00
|
|
|
VMS_DIR="$(pwd)"
|
|
|
|
DH_CONFIG_DIR="$(pwd)"
|
|
|
|
DH_ICON_DIR="$(pwd)/icons"
|
|
|
|
prefix=./
|
|
|
|
export "VMS_DIR" "DH_CONFIG_DIR" "DH_ICON_DIR" "TERMINAL" "replace" "prefix"
|
|
|
|
}
|
|
|
|
|
2023-03-26 19:32:45 +00:00
|
|
|
function mode_installed() {
|
2023-03-24 05:57:02 +00:00
|
|
|
source "$DH_CONFIG"
|
|
|
|
prefix=
|
|
|
|
export "prefix"
|
|
|
|
}
|
2023-03-28 01:41:03 +00:00
|
|
|
# installation ---------------------------
|
2023-03-26 19:32:45 +00:00
|
|
|
function check_gui_dependencies() {
|
2023-03-27 05:38:39 +00:00
|
|
|
[ -f "$PREFIX/yad" ] || echo $"Missing yad!"
|
2023-03-23 20:21:46 +00:00
|
|
|
}
|
|
|
|
|
2023-03-26 19:32:45 +00:00
|
|
|
function check_tui_dependencies() {
|
2023-03-27 05:38:39 +00:00
|
|
|
[ -f "$PREFIX/fzf" ] || echo $"Missing fzf!"
|
2023-03-23 20:21:46 +00:00
|
|
|
}
|
|
|
|
|
2023-03-26 19:32:45 +00:00
|
|
|
function set_variables() {
|
2023-03-27 05:38:39 +00:00
|
|
|
# DEBUG mod
|
|
|
|
#bash -x ./dh 2>&1 | tee output.log
|
2023-03-24 04:44:51 +00:00
|
|
|
#progname="${progname:="${0##*/}"}"
|
|
|
|
progname="DistroHopper"
|
2023-03-29 22:00:01 +00:00
|
|
|
version="0.77b"
|
2023-03-23 20:21:46 +00:00
|
|
|
#GTK_THEME="alt-dialog"
|
|
|
|
DH_CONFIG_DIR="$HOME/.config/distrohopper"
|
|
|
|
DH_CONFIG="$DH_CONFIG_DIR/distrohopper.conf"
|
2023-03-23 22:41:29 +00:00
|
|
|
DH_ICON_DIR="/usr/share/icons/distrohopper"
|
|
|
|
PREFIX="/usr/bin/"
|
|
|
|
TERMINAL=sakura
|
|
|
|
replace='"!"'
|
2023-03-24 04:44:51 +00:00
|
|
|
export "DH_CONFIG_DIR" "DH_CONFIG" "replace" "DH_ICON_DIR" "PREFIX" "TERMINAL"
|
|
|
|
portable
|
2023-03-23 20:21:46 +00:00
|
|
|
# Set traps to catch the signals and exit gracefully
|
|
|
|
trap "exit" INT
|
|
|
|
trap "exit" EXIT
|
|
|
|
}
|
|
|
|
|
2023-03-26 19:32:45 +00:00
|
|
|
function create_structure() {
|
2023-03-24 05:57:02 +00:00
|
|
|
source distrohopper.conf
|
2023-03-27 00:41:08 +00:00
|
|
|
echo $"creating config dir..."
|
2023-03-23 20:21:46 +00:00
|
|
|
mkdir -p "$DH_CONFIG_DIR"
|
2023-03-27 00:41:08 +00:00
|
|
|
echo $"creating icons dir as root..."
|
2023-03-28 04:02:38 +00:00
|
|
|
mkdir -p "$DH_ICON_DIR" >/dev/null 2>&1 || sudo mkdir -p "$DH_ICON_DIR"
|
2023-03-23 20:21:46 +00:00
|
|
|
}
|
|
|
|
|
2023-03-26 19:32:45 +00:00
|
|
|
function set_dir() {
|
2023-03-23 20:21:46 +00:00
|
|
|
NEWDIR="$(yad --file --directory --title="Where to save VMs?")"
|
|
|
|
VMS_DIR="$NEWDIR"
|
|
|
|
echo "VMS_DIR=\"$VMS_DIR\"
|
|
|
|
export \"VMS_DIR\"" >> "$DH_CONFIG"
|
|
|
|
export "VMS_DIR"
|
|
|
|
}
|
|
|
|
|
2023-03-26 19:32:45 +00:00
|
|
|
function install_prereq() {
|
2023-03-28 00:25:02 +00:00
|
|
|
# Find the current distribution and install dependecies
|
|
|
|
if [ -f /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
|
|
|
|
elif [[ -f /etc/debian_version ]]; then
|
|
|
|
sudo apt install qemu bash coreutils ovmf grep jq lsb procps python3 genisoimage usbutils util-linux sed spice-client-gtk swtpm wget xdg-user-dirs zsync unzip gettext yad fzf
|
|
|
|
elif grep -q void /etc/os-release; then
|
|
|
|
sudo xbps-install -S qemu bash coreutils grep jq procps-ng python3 util-linux sed spice-gtk swtpm usbutils wget xdg-user-dirs xrandr unzip zsync socat gettext yad fzf
|
|
|
|
elif grep -q fedora /etc/os-release; then
|
|
|
|
sudo dnf install qemu bash coreutils edk2-tools grep jq lsb procps python3 genisoimage usbutils util-linux sed spice-gtk-tools swtpm wget xdg-user-dirs xrandr unzip gettext yad fzf
|
2023-03-28 00:39:56 +00:00
|
|
|
elif grep -q nix /etc/os-release; then
|
|
|
|
echo "#TODO"
|
2023-03-28 00:25:02 +00:00
|
|
|
elif grep -q openSUSE /etc/os-release; then
|
|
|
|
# openSUSE supports dnf, but the default is zypper
|
|
|
|
if hash dnf 2>/dev/null; then
|
|
|
|
sudo dnf install qemu bash coreutils edk2-tools grep jq lsb procps python3 genisoimage usbutils util-linux sed spice-gtk-tools swtpm wget xdg-user-dirs xrandr unzip gettext yad fzf
|
|
|
|
else
|
|
|
|
echo "ERROR: I currently don't have support for your distro"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "ERROR: I currently don't have support for your distro"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
2023-03-23 20:21:46 +00:00
|
|
|
}
|
|
|
|
|
2023-03-26 19:32:45 +00:00
|
|
|
function install_dh() {
|
2023-03-24 05:57:02 +00:00
|
|
|
cp dh quickget quickemu macrecovery windowskey "$PREFIX" >/dev/null 2>&1 || sudo cp dh quickget quickemu macrecovery windowskey "$PREFIX"
|
2023-03-23 20:21:46 +00:00
|
|
|
# quickget also to config directory for adding new distros...
|
2023-03-24 05:57:02 +00:00
|
|
|
cp quickget "$DH_CONFIG_DIR/"
|
2023-03-27 00:41:08 +00:00
|
|
|
echo $"Copying icons..."
|
2023-03-24 05:57:02 +00:00
|
|
|
cp icons/* "$DH_ICON_DIR/" >/dev/null 2>&1 || sudo cp icons/* "$DH_ICON_DIR/"
|
2023-03-27 00:41:08 +00:00
|
|
|
echo $"Copying to config dir..."
|
2023-03-24 05:57:02 +00:00
|
|
|
cp -r ready "$DH_CONFIG_DIR/"
|
|
|
|
cp -r supported "$DH_CONFIG_DIR/"
|
2023-03-27 05:38:39 +00:00
|
|
|
cp -r locale "$DH_CONFIG_DIR/"
|
2023-03-23 20:21:46 +00:00
|
|
|
}
|
|
|
|
|
2023-03-26 19:32:45 +00:00
|
|
|
function install_process() {
|
2023-03-23 20:21:46 +00:00
|
|
|
check_tui_dependencies
|
|
|
|
check_gui_dependencies
|
2023-03-24 05:57:02 +00:00
|
|
|
#check_quickemu_dependencies
|
2023-03-27 00:41:08 +00:00
|
|
|
echo $"Creating directory structure..." \
|
2023-03-23 20:21:46 +00:00
|
|
|
&& create_structure \
|
2023-03-27 00:41:08 +00:00
|
|
|
&& echo $"Setting up directory..." \
|
2023-03-23 20:21:46 +00:00
|
|
|
&& set_dir \
|
2023-03-27 00:41:08 +00:00
|
|
|
&& echo $"Installing needed..." \
|
2023-03-23 20:21:46 +00:00
|
|
|
&& install_prereq \
|
2023-03-27 00:41:08 +00:00
|
|
|
&& echo $"Installing DistroHopper to bin..." \
|
2023-03-24 04:44:51 +00:00
|
|
|
&& install_dh
|
2023-03-23 20:21:46 +00:00
|
|
|
}
|
2023-03-28 01:41:03 +00:00
|
|
|
# basic -----------------------------------
|
2023-03-26 19:32:45 +00:00
|
|
|
function renew_ready() {
|
2023-03-24 04:44:51 +00:00
|
|
|
cd "$VMS_DIR" || exit 1
|
2023-03-28 04:02:38 +00:00
|
|
|
rm "$DH_CONFIG_DIR"/ready/*.desktop >/dev/null 2>&1
|
2023-03-27 05:38:39 +00:00
|
|
|
# for files in "$VMS_DIR"/*; do
|
|
|
|
# if [ ! -e *.conf ]; then
|
|
|
|
# echo $"No .conf files found"
|
|
|
|
# return
|
|
|
|
# fi
|
2023-03-24 04:44:51 +00:00
|
|
|
for vm_conf in *.conf; do
|
|
|
|
if [ "$vm_conf" == "distrohopper.conf" ]; then
|
|
|
|
continue # skip processing distrohopper.conf
|
|
|
|
fi
|
|
|
|
vm_desktop=$(basename "$VMS_DIR/$vm_conf" .conf)
|
|
|
|
# Use fuzzy matching to find the best matching icon file (ready to run VMs)
|
|
|
|
icon_name=$(basename "$VMS_DIR/$vm_conf" .conf | cut -d'-' -f -2)
|
|
|
|
icon_file=$(find "$DH_ICON_DIR" -type f -iname "${icon_name// /}.*")
|
|
|
|
# If no icon was found, try shorter name (ready to run VMs)
|
|
|
|
if [ -z "$icon_file" ]; then
|
|
|
|
icon_name=$(basename "$VMS_DIR/$vm_conf" .conf | cut -d'-' -f1)
|
|
|
|
icon_file=$(find "$DH_ICON_DIR" -type f -iname "${icon_name// /}.*")
|
|
|
|
elif [ -z "$icon_file" ]; then
|
|
|
|
icon_file="$DH_ICON_DIR/tux.svg"
|
|
|
|
fi
|
|
|
|
# content of desktop files (ready to run VMs)
|
|
|
|
desktop_file_content="[Desktop Entry]
|
|
|
|
Type=Application
|
|
|
|
Name=$vm_desktop
|
|
|
|
Exec=sh -c 'cd \"$VMS_DIR\" && "$prefix"quickemu -vm $vm_conf'
|
|
|
|
Icon=$icon_file
|
|
|
|
Categories=System;Virtualization;"
|
|
|
|
# create desktop files (ready to run VMs)
|
|
|
|
echo "$desktop_file_content" > "$DH_CONFIG_DIR"/ready/"$vm_desktop".desktop
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2023-03-26 19:32:45 +00:00
|
|
|
function renew_supported() {
|
2023-03-28 04:02:38 +00:00
|
|
|
rm "$DH_CONFIG_DIR"/supported/*.desktop >/dev/null 2>&1
|
2023-03-23 20:21:46 +00:00
|
|
|
# get supported VMs
|
2023-03-24 04:44:51 +00:00
|
|
|
"$prefix"quickget | sed 1d | cut -d':' -f2 | grep -o '[^ ]*' > "$DH_CONFIG_DIR/supported.md"
|
2023-03-23 20:21:46 +00:00
|
|
|
while read -r get_name; do
|
|
|
|
vm_desktop=$(echo "$get_name" | tr ' ' '_')
|
2023-03-29 20:06:49 +00:00
|
|
|
releases=$("$prefix"quickget "$vm_desktop" | grep 'Releases' | cut -d':' -f2 | sed 's/^ //' | sed 's/ *$//')
|
|
|
|
editions=$("$prefix"quickget "$vm_desktop" | grep 'Editions' | cut -d':' -f2 | sed 's/^ //' | sed 's/ *$//')
|
2023-03-23 20:21:46 +00:00
|
|
|
icon_name="$DH_ICON_DIR/$get_name"
|
|
|
|
if [ -f "$icon_name.svg" ]; then
|
|
|
|
icon_file="$icon_name.svg"
|
|
|
|
elif [ -f "$icon_name.png" ]; then
|
|
|
|
icon_file="$icon_name.png"
|
|
|
|
else
|
|
|
|
icon_file="$DH_ICON_DIR/tux.svg"
|
|
|
|
fi
|
2023-03-29 20:06:49 +00:00
|
|
|
echo $"Creating desktop file for $vm_desktop..."
|
|
|
|
echo ""
|
2023-03-23 20:21:46 +00:00
|
|
|
# Check if there are editions
|
|
|
|
if [ -z "$editions" ]; then
|
2023-03-29 20:06:49 +00:00
|
|
|
cat <<EOF > "$DH_CONFIG_DIR"/supported/"$vm_desktop".desktop
|
|
|
|
[Desktop Entry]
|
2023-03-23 20:21:46 +00:00
|
|
|
Type=Application
|
|
|
|
Name=$get_name
|
|
|
|
releases=$releases
|
|
|
|
replace=$replace
|
2023-03-29 20:06:49 +00:00
|
|
|
Exec=sh -c 'cd $VMS_DIR && yad --form --field="Release:CB" "${releases// /$replace}" | cut -d'|' -f1 | xargs -I{} sh -c "$prefix"quickget $get_name {}'
|
2023-03-23 20:21:46 +00:00
|
|
|
Icon=$icon_file
|
2023-03-29 20:06:49 +00:00
|
|
|
Categories=System;Virtualization;
|
2023-03-23 20:21:46 +00:00
|
|
|
|
2023-03-29 20:06:49 +00:00
|
|
|
EOF
|
2023-03-26 15:19:40 +00:00
|
|
|
else
|
2023-03-29 20:06:49 +00:00
|
|
|
cat <<EOF > "$DH_CONFIG_DIR"/supported/"$vm_desktop".desktop
|
|
|
|
[Desktop Entry]
|
2023-03-26 15:19:40 +00:00
|
|
|
Type=Application
|
|
|
|
Name=$get_name
|
|
|
|
releases=$releases
|
|
|
|
editions=$editions
|
|
|
|
replace=$replace
|
2023-03-29 20:06:49 +00:00
|
|
|
Exec=sh -c 'cd $VMS_DIR && yad --form --separator=" " --field="Release:CB" "${releases// /$replace}" --field="Edition:CB" "${editions// /$replace}" | xargs -I{} sh -c "$prefixquickget $get_name {}'
|
2023-03-26 15:19:40 +00:00
|
|
|
Icon=$icon_file
|
2023-03-29 20:06:49 +00:00
|
|
|
Categories=System;Virtualization;
|
|
|
|
|
|
|
|
EOF
|
2023-03-26 15:19:40 +00:00
|
|
|
fi
|
2023-03-29 20:06:49 +00:00
|
|
|
done < "$DH_CONFIG_DIR"/supported.md
|
2023-03-26 15:19:40 +00:00
|
|
|
}
|
|
|
|
|
2023-03-26 19:32:45 +00:00
|
|
|
function run_gui() {
|
2023-03-24 04:44:51 +00:00
|
|
|
check_gui_dependencies
|
2023-03-23 20:21:46 +00:00
|
|
|
key=$((RANDOM % 9000 + 1000))
|
2023-03-23 22:41:29 +00:00
|
|
|
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 &
|
2023-03-24 04:44:51 +00:00
|
|
|
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"
|
2023-03-23 20:21:46 +00:00
|
|
|
}
|
|
|
|
|
2023-03-26 19:32:45 +00:00
|
|
|
function run_tui() {
|
2023-03-24 04:44:51 +00:00
|
|
|
check_tui_dependencies
|
2023-03-28 04:02:38 +00:00
|
|
|
cd "$VMS_DIR" || exit 1
|
2023-03-20 01:39:55 +00:00
|
|
|
vms=(*.conf)
|
2023-03-29 18:16:55 +00:00
|
|
|
printf $" Prepared VMs:\n-------------\n\n"
|
2023-03-20 01:39:55 +00:00
|
|
|
# Check if there are any VMs
|
|
|
|
if [ ${#vms[@]} -eq 0 ]; then
|
2023-03-27 00:41:08 +00:00
|
|
|
echo $"No VMs found."
|
2023-03-20 01:39:55 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
# Print the names of the available VMs
|
|
|
|
printf "%s\n" "${vms[@]%.*}"
|
|
|
|
echo "-------------"
|
|
|
|
# Action prompt
|
2023-03-29 18:16:55 +00:00
|
|
|
echo $" Do you want to create a new VM? (c)"
|
|
|
|
printf $" or run an existing one? (press anything)\n"
|
2023-03-20 01:39:55 +00:00
|
|
|
read -rn 1 -s start
|
|
|
|
case $start in
|
|
|
|
c )
|
|
|
|
todo="create"
|
|
|
|
;;
|
|
|
|
esac
|
2023-03-29 18:16:55 +00:00
|
|
|
|
2023-03-20 01:39:55 +00:00
|
|
|
# If the user chose to create a new VM
|
|
|
|
if [ "$todo" = "create" ]; then
|
2023-03-24 04:44:51 +00:00
|
|
|
os=$("$prefix"quickget | sed 1d | cut -d':' -f2 | grep -o '[^ ]*' | fzf --cycle --header='Choose OS to download
|
2023-03-16 16:37:46 +00:00
|
|
|
or CTRL-c or ESC to quit')
|
2023-03-29 18:16:55 +00:00
|
|
|
|
2023-03-23 20:21:46 +00:00
|
|
|
# If the OS is Windows
|
|
|
|
if [ "$os" = windows ]; then
|
|
|
|
answer=$(echo "Default English
|
2023-03-16 16:37:46 +00:00
|
|
|
Choose other language" | fzf --cycle)
|
2023-03-29 18:16:55 +00:00
|
|
|
|
2023-03-23 20:21:46 +00:00
|
|
|
# If the user wants another windows language
|
|
|
|
if [ "$answer" = "Choose other language" ]; then
|
|
|
|
wrelease=$(echo "8
|
2023-03-16 16:37:46 +00:00
|
|
|
10
|
|
|
|
11" | fzf --cycle)
|
2023-03-29 18:16:55 +00:00
|
|
|
|
2023-03-23 20:21:46 +00:00
|
|
|
# get window language list
|
2023-03-24 04:44:51 +00:00
|
|
|
wlend=$(($(cat "$prefix"quickget | sed '/Arabic/,$!d' | grep -n '}' | cut -d':' -f1 | head -n 1) - 1))
|
2023-03-29 18:16:55 +00:00
|
|
|
|
2023-03-23 20:21:46 +00:00
|
|
|
# get windows language
|
2023-03-24 04:44:51 +00:00
|
|
|
wlang=$(cat "$prefix"quickget | sed '/Arabic/,$!d' | head -n $wlend | cut -d'=' -f2 | tail -c +2 | head -c -2 | sed 's/^[ \t]*//' | fzf --cycle --header='Choose Language
|
2023-03-16 16:37:46 +00:00
|
|
|
or CTRL-c or ESC to quit')
|
2023-03-29 18:16:55 +00:00
|
|
|
|
2023-03-23 20:21:46 +00:00
|
|
|
# downloading windows
|
2023-03-29 18:16:55 +00:00
|
|
|
printf $"\n Trying to download Windows %s %s...\n\n" "$wrelease" "$wlang"
|
2023-03-24 04:44:51 +00:00
|
|
|
"$prefix"quickget "windows" "$wrelease" "$wlang"
|
2023-03-23 20:21:46 +00:00
|
|
|
fi
|
2023-03-16 16:37:46 +00:00
|
|
|
fi
|
2023-03-29 18:16:55 +00:00
|
|
|
|
2023-03-23 20:21:46 +00:00
|
|
|
# Get the release and edition to download, if necessary
|
2023-03-24 04:44:51 +00:00
|
|
|
choices=$("$prefix"quickget "$os" | sed 1d)
|
2023-03-29 18:16:55 +00:00
|
|
|
|
2023-03-23 20:21:46 +00:00
|
|
|
if [ "$(echo "$choices" | wc -l)" = 1 ]; then
|
2023-03-29 18:16:55 +00:00
|
|
|
|
2023-03-23 20:21:46 +00:00
|
|
|
# get release
|
|
|
|
release=$(echo "$choices" | grep 'Releases' | cut -d':' -f2 | grep -o '[^ ]*' | fzf --cycle --header='Choose Release
|
2023-03-16 16:37:46 +00:00
|
|
|
or CTRL-c or ESC to quit')
|
2023-03-29 18:16:55 +00:00
|
|
|
|
2023-03-23 20:21:46 +00:00
|
|
|
# downloading
|
2023-03-29 18:16:55 +00:00
|
|
|
printf $"\n Trying to download %s %s...\n\n" "$os" "$release"
|
2023-03-24 04:44:51 +00:00
|
|
|
"$prefix"quickget "$os" "$release"
|
2023-03-23 20:21:46 +00:00
|
|
|
else
|
2023-03-29 18:16:55 +00:00
|
|
|
|
2023-03-23 20:21:46 +00:00
|
|
|
# get release
|
|
|
|
release=$(echo "$choices" | grep 'Releases' | cut -d':' -f2 | grep -o '[^ ]*' | fzf --cycle --header='Choose Release
|
2023-03-16 16:37:46 +00:00
|
|
|
or CTRL-c or ESC to quit')
|
2023-03-29 18:16:55 +00:00
|
|
|
|
2023-03-23 20:21:46 +00:00
|
|
|
# get edition
|
|
|
|
edition=$(echo "$choices" | grep 'Editions' | cut -d':' -f2 | grep -o '[^ ]*' | fzf --cycle --header='Choose Edition
|
2023-03-16 16:37:46 +00:00
|
|
|
or CTRL-c or ESC to quit')
|
2023-03-29 18:16:55 +00:00
|
|
|
|
2023-03-23 20:21:46 +00:00
|
|
|
# downloading
|
2023-03-29 18:16:55 +00:00
|
|
|
printf $"\n Trying to download %s %s %s...\n\n" "$os" "$release" "$edition"
|
2023-03-24 04:44:51 +00:00
|
|
|
"$prefix"quickget "$os" "$release" "$edition"
|
2023-03-23 20:21:46 +00:00
|
|
|
fi
|
2023-03-29 18:16:55 +00:00
|
|
|
|
2023-03-23 20:21:46 +00:00
|
|
|
# choose VM to run
|
|
|
|
choosed=$(echo "$(ls ./***.conf 2>/dev/null | sed 's/\.conf$//')" | fzf --cycle --header='Choose VM to run
|
2023-03-16 16:37:46 +00:00
|
|
|
or CTRL-c or ESC to quit')
|
2023-03-29 18:16:55 +00:00
|
|
|
|
2023-03-23 20:21:46 +00:00
|
|
|
# Run choosed VM
|
2023-03-29 18:16:55 +00:00
|
|
|
printf $"\n Starting %s...\n\n" "$choosed"
|
2023-03-24 04:44:51 +00:00
|
|
|
"$prefix"quickemu -vm "$choosed.conf"
|
2023-03-23 20:21:46 +00:00
|
|
|
fi
|
|
|
|
}
|
2023-03-29 18:16:55 +00:00
|
|
|
|
2023-03-23 20:21:46 +00:00
|
|
|
# more
|
2023-03-26 19:32:45 +00:00
|
|
|
function isos_to_dir() {
|
2023-03-23 20:21:46 +00:00
|
|
|
yad --file --directory > target
|
|
|
|
cd "$VMS_DIR" || exit 1
|
2023-03-27 05:38:39 +00:00
|
|
|
# shellcheck disable=2154
|
|
|
|
cp ./*glob*/*.iso "$target"
|
2023-03-23 20:21:46 +00:00
|
|
|
}
|
2023-03-27 05:38:39 +00:00
|
|
|
# shellcheck disable=2086
|
2023-03-26 19:32:45 +00:00
|
|
|
function add_distro() {
|
2023-03-23 20:21:46 +00:00
|
|
|
TMP_DIR="/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)"
|
|
|
|
NAME="$(cat ${TMP_DIR}/template.tmp | cut -d'|' -f2)"
|
|
|
|
RELEASES="$(cat ${TMP_DIR}/template.tmp | cut -d'|' -f3)"
|
|
|
|
EDITIONS="$(cat ${TMP_DIR}/template.tmp | cut -d'|' -f4)"
|
|
|
|
URL="$(cat ${TMP_DIR}/template.tmp | cut -d'|' -f5)"
|
|
|
|
ISO="$(cat ${TMP_DIR}/template.tmp | cut -d'|' -f6)"
|
|
|
|
CHECKSUM_FILE="$(cat ${TMP_DIR}/template.tmp | cut -d'|' -f7)"
|
2023-03-29 18:16:55 +00:00
|
|
|
|
|
|
|
cat <<EOF > "${TMP_DIR}"/template.tmp
|
|
|
|
#32
|
|
|
|
|
|
|
|
$NAME) PRETTY_NAME="$PRETTY_NAME";;
|
|
|
|
|
|
|
|
#184+
|
|
|
|
|
|
|
|
$NAME \\
|
|
|
|
|
|
|
|
#262+
|
|
|
|
|
|
|
|
function releases_$NAME() {
|
2023-03-23 20:21:46 +00:00
|
|
|
echo $RELEASES
|
|
|
|
}
|
2023-03-29 18:16:55 +00:00
|
|
|
|
|
|
|
function editions_$NAME() {
|
2023-03-23 20:21:46 +00:00
|
|
|
echo $EDITIONS
|
|
|
|
}
|
2023-03-29 18:16:55 +00:00
|
|
|
|
|
|
|
#1052+
|
|
|
|
|
|
|
|
function get_$NAME() {
|
|
|
|
local EDITION="\${1:-}"
|
2023-03-23 20:21:46 +00:00
|
|
|
local HASH=""
|
|
|
|
local ISO="$ISO"
|
|
|
|
local URL="$URL"
|
2023-03-29 18:16:55 +00:00
|
|
|
HASH="\$(wget -q -O- \${URL}/\${CHECKSUM_FILE} | grep (\${ISO} | cut -d' ' -f4)"
|
|
|
|
echo "\${URL}/\${ISO}" "\${HASH}"
|
2023-03-23 20:21:46 +00:00
|
|
|
}
|
2023-03-29 18:16:55 +00:00
|
|
|
|
|
|
|
EOF
|
|
|
|
echo "Done"
|
|
|
|
meld "${TMP_DIR}"/template.tmp "$DH_CONFIG_DIR"/quickget
|
2023-03-23 20:21:46 +00:00
|
|
|
}
|
|
|
|
|
2023-03-27 00:38:27 +00:00
|
|
|
function sort_functions() {
|
2023-03-27 05:38:39 +00:00
|
|
|
#TODO
|
2023-03-27 00:38:27 +00:00
|
|
|
# Get the name of the script from the command line argument
|
|
|
|
script_name=$1
|
|
|
|
# Get a list of all the function names in the script
|
|
|
|
function_names=$(grep -oP '^[[:space:]]*function \K\w+' "$script_name")
|
|
|
|
# Sort the function names alphabetically
|
|
|
|
sorted_function_names=$(echo "$function_names" | sort)
|
|
|
|
# Loop through the sorted function names and print the function definitions
|
|
|
|
for function_name in $sorted_function_names
|
|
|
|
do
|
|
|
|
# Print the function definition to stdout
|
2023-03-27 05:38:39 +00:00
|
|
|
grep -A "$(wc -l < "$script_name")" -w "function $function_name" "$script_name"
|
2023-03-27 00:38:27 +00:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2023-03-29 22:00:01 +00:00
|
|
|
function translate() {
|
2023-03-29 18:16:55 +00:00
|
|
|
echo $"Which language change? [en,cs]"
|
|
|
|
echo $"If you want create new one, insert two digit language code..."
|
2023-03-27 05:38:39 +00:00
|
|
|
read -rn 2 -s lang
|
|
|
|
echo $"Choosed language is: $lang"
|
|
|
|
echo $"Dumping language source..."
|
|
|
|
bash --dump-po-strings dh > "$DH_CONFIG_DIR"/locale/dh-source.pot
|
|
|
|
echo $"Merging changes... (Do it yourself)"
|
|
|
|
meld "$DH_CONFIG_DIR"/locale/dh-source.pot "$DH_CONFIG_DIR"/locale/distrohopper-"$lang".pot
|
|
|
|
echo $"Generating .mo file..."
|
|
|
|
msgfmt -o "$DH_CONFIG_DIR"/locale/distrohopper-"$lang".mo "$DH_CONFIG_DIR"/locale/distrohopper-"$lang".pot
|
|
|
|
echo $"Copying translation to '/usr/share/local'..."
|
|
|
|
sudo cp "$DH_CONFIG_DIR"/locale/distrohopper-"$lang".mo /usr/share/locale/"$lang"/LC_MESSAGES/distrohopper.mo
|
2023-03-27 00:40:53 +00:00
|
|
|
}
|
2023-03-28 01:41:03 +00:00
|
|
|
# run --------------------------------------
|
2023-03-23 20:21:46 +00:00
|
|
|
set_variables
|
2023-03-26 19:31:30 +00:00
|
|
|
|
|
|
|
if [[ $# -eq 0 ]]; then
|
2023-03-27 00:41:08 +00:00
|
|
|
printf $"No argumet provided!\n\n"
|
2023-03-26 19:31:30 +00:00
|
|
|
show_help
|
|
|
|
fi
|
2023-03-24 04:44:51 +00:00
|
|
|
|
2023-03-26 15:09:39 +00:00
|
|
|
while [[ $# -gt 0 ]]
|
|
|
|
do
|
|
|
|
key="$1"
|
|
|
|
case $key in
|
2023-03-28 01:41:03 +00:00
|
|
|
h|help)
|
2023-03-26 15:09:39 +00:00
|
|
|
show_help
|
|
|
|
shift
|
|
|
|
;;
|
2023-03-28 01:41:03 +00:00
|
|
|
d|dir)
|
2023-03-26 15:09:39 +00:00
|
|
|
set_dir
|
|
|
|
shift
|
|
|
|
;;
|
2023-03-28 01:41:03 +00:00
|
|
|
i|install)
|
2023-03-27 00:41:08 +00:00
|
|
|
echo $"Starting installation..."
|
2023-03-26 15:09:39 +00:00
|
|
|
install_process
|
|
|
|
shift
|
|
|
|
;;
|
2023-03-28 01:41:03 +00:00
|
|
|
m|mode)
|
2023-03-27 00:41:08 +00:00
|
|
|
echo $"Switching to portable mode!"
|
2023-03-26 15:09:39 +00:00
|
|
|
mode_portable
|
|
|
|
shift
|
|
|
|
;;
|
2023-03-28 01:41:03 +00:00
|
|
|
s|supported)
|
2023-03-27 00:41:08 +00:00
|
|
|
echo $"Updating supported VMs..."
|
2023-03-26 15:09:39 +00:00
|
|
|
renew_supported
|
|
|
|
shift
|
|
|
|
;;
|
2023-03-28 01:41:03 +00:00
|
|
|
r|ready)
|
2023-03-27 00:41:08 +00:00
|
|
|
echo $"Updating ready VMs..."
|
2023-03-26 15:09:39 +00:00
|
|
|
renew_ready
|
|
|
|
shift
|
|
|
|
;;
|
2023-03-28 01:41:03 +00:00
|
|
|
t|tui)
|
2023-03-27 00:41:08 +00:00
|
|
|
echo $"Running TUI..."
|
2023-03-26 15:09:39 +00:00
|
|
|
run_tui
|
|
|
|
shift
|
|
|
|
;;
|
2023-03-28 01:41:03 +00:00
|
|
|
g|gui)
|
2023-03-27 00:41:08 +00:00
|
|
|
echo $"Starting DistroHopper GUI..."
|
2023-03-26 15:09:39 +00:00
|
|
|
run_gui
|
|
|
|
shift
|
|
|
|
;;
|
2023-03-28 01:41:03 +00:00
|
|
|
a|add)
|
2023-03-27 00:41:08 +00:00
|
|
|
echo $"Adding new distro started..."
|
2023-03-26 15:09:39 +00:00
|
|
|
add_distro
|
|
|
|
shift
|
|
|
|
;;
|
2023-03-28 01:41:03 +00:00
|
|
|
f|functions)
|
2023-03-27 00:41:08 +00:00
|
|
|
echo $"Sorting functions in template..."
|
2023-03-26 15:09:39 +00:00
|
|
|
sort_functions
|
|
|
|
shift
|
|
|
|
;;
|
2023-03-28 01:41:03 +00:00
|
|
|
p|push)
|
2023-03-27 00:41:08 +00:00
|
|
|
echo $"Pushing changes to... #TODO"
|
2023-03-26 15:09:39 +00:00
|
|
|
push_changes
|
|
|
|
shift
|
|
|
|
;;
|
2023-03-28 01:41:03 +00:00
|
|
|
c|copy)
|
2023-03-27 00:41:08 +00:00
|
|
|
echo $"Copying ISOs to dir. It will take some time..."
|
2023-03-26 15:09:39 +00:00
|
|
|
isos_to_dir
|
|
|
|
shift
|
|
|
|
;;
|
2023-03-28 01:41:03 +00:00
|
|
|
l|language)
|
2023-03-29 22:00:01 +00:00
|
|
|
translate
|
2023-03-27 00:41:08 +00:00
|
|
|
shift
|
|
|
|
;;
|
2023-03-26 15:09:39 +00:00
|
|
|
*)
|
2023-03-27 05:38:39 +00:00
|
|
|
echo $"Invalid option: $1"
|
|
|
|
echo ""
|
2023-03-26 15:09:39 +00:00
|
|
|
show_help
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
2023-03-23 23:10:24 +00:00
|
|
|
|
2023-03-23 20:21:46 +00:00
|
|
|
some_bugs
|
|
|
|
|
2023-03-16 16:37:46 +00:00
|
|
|
exit 0
|