mirror of
https://github.com/Kron4ek/Conty
synced 2024-11-16 19:50:06 +01:00
Don't parse own arguments if the script is a symlink
This commit is contained in:
parent
d2fda8cbcf
commit
cc69e5361b
1 changed files with 106 additions and 99 deletions
|
@ -43,7 +43,7 @@ mount_point="${working_dir}"/mnt
|
|||
# a problem with mounting the image due to an incorrectly calculated offset.
|
||||
|
||||
# The size of this script
|
||||
scriptsize=25233
|
||||
scriptsize=26146
|
||||
|
||||
# The size of the utils archive
|
||||
utilssize=2542302
|
||||
|
@ -65,7 +65,13 @@ dwarfs_comp_arguments="-l7 -C zstd:level=19 --metadata-compression null \
|
|||
-S 22 -B 2 --order nilsimsa:255:40000:40000 \
|
||||
--bloom-filter-size 11 -W 15 -w 3"
|
||||
|
||||
if [ "$1" = "--help" ] || [ "$1" = "-h" ] || ([ -z "$1" ] && [ ! -L "${script_literal}" ]); then
|
||||
unset script_is_symlink
|
||||
if [ -L "${script_literal}" ]; then
|
||||
script_is_symlink=1
|
||||
fi
|
||||
|
||||
if [ -z "${script_is_symlink}" ]; then
|
||||
if [ "$1" = "--help" ] || [ "$1" = "-h" ] || [ -z "$1" ]; then
|
||||
echo "Usage: ./conty.sh command command_arguments"
|
||||
echo
|
||||
echo "Arguments:"
|
||||
|
@ -150,14 +156,15 @@ if [ "$1" = "--help" ] || [ "$1" = "-h" ] || ([ -z "$1" ] && [ ! -L "${script_li
|
|||
echo "If you are using an Nvidia GPU, please read the information"
|
||||
echo "here: https://github.com/Kron4ek/Conty#known-issues"
|
||||
exit
|
||||
elif [ "$1" = "-v" ]; then
|
||||
elif [ "$1" = "-v" ]; then
|
||||
echo "${script_version}"
|
||||
|
||||
exit
|
||||
elif [ "$1" = "-o" ]; then
|
||||
elif [ "$1" = "-o" ]; then
|
||||
echo ${offset}
|
||||
|
||||
exit
|
||||
fi
|
||||
fi
|
||||
|
||||
show_msg () {
|
||||
|
@ -315,7 +322,7 @@ else
|
|||
show_msg "Using system-wide ${mount_tool} and bwrap"
|
||||
fi
|
||||
|
||||
if [ "$1" = "-e" ]; then
|
||||
if [ "$1" = "-e" ] && [ -z "${script_is_symlink}" ]; then
|
||||
if command -v "${extraction_tool}" 1>/dev/null; then
|
||||
if [ "${dwarfs_image}" = 1 ]; then
|
||||
echo "Extracting the image..."
|
||||
|
@ -333,12 +340,12 @@ if [ "$1" = "-e" ]; then
|
|||
exit
|
||||
fi
|
||||
|
||||
if [ "$1" = "-H" ]; then
|
||||
if [ "$1" = "-H" ] && [ -z "${script_is_symlink}" ]; then
|
||||
launch_wrapper "${bwrap}" --help
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ "$1" = "-u" ] || [ "$1" = "-U" ]; then
|
||||
if ([ "$1" = "-u" ] || [ "$1" = "-U" ]) && [ -z "${script_is_symlink}" ]; then
|
||||
OLD_PWD="${PWD}"
|
||||
|
||||
# Check if the current directory is writable
|
||||
|
@ -728,7 +735,7 @@ if [ "$(ls "${mount_point}" 2>/dev/null)" ] || \
|
|||
launch_wrapper "${mount_tool}" "${script}" "${mount_point}" -o offset="${offset}" -o debuglevel=error -o workers="${dwarfs_num_workers}" \
|
||||
-o mlock=try -o no_cache_image -o cache_files -o cachesize="${dwarfs_cache_size}"; then
|
||||
|
||||
if [ "$1" = "-m" ]; then
|
||||
if [ "$1" = "-m" ] && [ -z "${script_is_symlink}" ]; then
|
||||
if [ ! -f "${working_dir}"/running_mount ]; then
|
||||
echo 1 > "${working_dir}"/running_mount
|
||||
echo "The image has been mounted to ${mount_point}"
|
||||
|
@ -740,7 +747,7 @@ if [ "$(ls "${mount_point}" 2>/dev/null)" ] || \
|
|||
exit
|
||||
fi
|
||||
|
||||
if [ "$1" = "-V" ]; then
|
||||
if [ "$1" = "-V" ] && [ -z "${script_is_symlink}" ]; then
|
||||
if [ -f "${mount_point}"/version ]; then
|
||||
cat "${mount_point}"/version
|
||||
else
|
||||
|
@ -756,7 +763,7 @@ if [ "$(ls "${mount_point}" 2>/dev/null)" ] || \
|
|||
|
||||
export CUSTOM_PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/lib/jvm/default/bin:/usr/local/bin:/usr/local/sbin:${PATH}"
|
||||
|
||||
if [ "$1" = "-l" ]; then
|
||||
if [ "$1" = "-l" ] && [ -z "${script_is_symlink}" ]; then
|
||||
run_bwrap --ro-bind "${mount_point}"/var /var pacman -Q
|
||||
exit
|
||||
fi
|
||||
|
@ -788,7 +795,7 @@ if [ "$(ls "${mount_point}" 2>/dev/null)" ] || \
|
|||
fi
|
||||
fi
|
||||
|
||||
if [ -L "${script_literal}" ] && [ -f "${mount_point}"/usr/bin/"${script_name}" ]; then
|
||||
if [ -n "${script_is_symlink}" ] && [ -f "${mount_point}"/usr/bin/"${script_name}" ]; then
|
||||
export CUSTOM_PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/lib/jvm/default/bin"
|
||||
|
||||
show_msg "Autostarting ${script_name}"
|
||||
|
|
Loading…
Reference in a new issue