qq2clone/inst_fragment.bash

51 lines
1.4 KiB
Bash
Raw Normal View History

2021-07-14 05:41:59 +00:00
# Tail end of the installer script, following the tar archive
[[ -z "$HOME" ]] &&
{ echo '$HOME must be defined'; exit 1; }
temp_dir="$(mktemp -d)" ||
{ echo "Failed to create temp directory"; exit 1; }
{
echo "$archive" | base64 -d > "${temp_dir}/archive.tgz" &&
cd "$temp_dir" &&
tar -xzf archive.tgz
} || { echo "Problem unpacking data to $temp_dir"; exit 1; }
declare input="" location="${HOME}/storage-qq2clone"
while [[ ! "$input" =~ ^(y|n|Y|N)$ ]]; do
echo "[y/n] Use default storage directory '$location'?"
read -rn1 input
done
while [[ ! "$input" =~ (y|Y) ]]; do
echo "Type in new location"
read -r location
while [[ ! "$input" =~ ^(y|n|Y|N)$ ]]; do
echo "[y/n] Accept location \'$location\' ?"
read -rn 1 input
done
[[ "$input" =~ (y|Y) ]] && break
done
{
mkdir -p "${HOME}/.config" &&
echo "$location" > "${HOME}/.config/qq2clone"
} || { echo "Failed to create ${HOME}/.config/qq2clone"; exit 1; }
{
mkdir -p "$location" &&
touch "$location/qq2clone" &&
touch "$location/lv_api_do"
} || { echo "Cannot create/write to '$location'"; exit 1; }
{
mv "${temp_dir}/qq2clone" "${location}/" &&
mv "${temp_dir}/lv_api_do" "${location}/"
} || { echo "Unexpected filesystem permissions error"; exit 1; }
# TODO Replace qq2clone first_time_setup
# TODO offer to 'install' by placing in path
rm -rf "${temp_dir:?}" &>/dev/null