Files
lnx-arch/scripts/99_download.sh
tuxwarrior fb954b8fa3 u
2024-04-30 20:34:33 -05:00

69 lines
1.6 KiB
Bash

#!/usr/bin/env bash
# klevstul
echo "<< 99_download.sh >>"
user=poq
base_dots_url=https://git.mz.fo/fro/lnx-arch/raw/branch/master
targz_dots_url=https://git.mz.fo/fro/lnx-arch/archive/master.tar.gz
clone_trg=/tmp
dots_trg=${clone_trg}/lnx-arch/dots
if [ "$EUID" -ne 0 ]
then echo "error: run as 'root'"
exit
fi
this_file_name=`basename "$0"`
if [ $# -lt 1 ]; then
echo "usage: '$this_file_name {all}'"
exit 1
fi
operation=$1
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
# helper function
download_repo() {
_targz_url=$1
# make clone target directory, if it doesn't exist
mkdir -p ${clone_trg}
# instead of doing a git clone (like `git clone ${clone_url} ${clone_trg}`),
# where i would have emptied the target dir each time, i download the
# source as a tar.gz.
wget --show-progress ${_targz_url} -O ${clone_trg}/tmp.tar.gz
tar -xzf ${clone_trg}/tmp.tar.gz -C ${clone_trg}
rm ${clone_trg}/tmp.tar.gz
}
# download all dots (dot files) from repo
if [ ${operation} == "dots" ] ; then
echo "***** ${operation} *****"
download_repo ${targz_dots_url}
tree ${clone_trg}/lnx-arch
target_file_name=hyprland.conf
target_file_path=/home/${user}/.config/hypr/${target_file_name}
cp -f ${dots_trg}/hyprland/${target_file_name} ${target_file_path}
chown ${user}:${user} ${target_file_path}
ls -al ${target_file_path}
target_file_name=hyprpaper.conf
target_file_path=/home/${user}/.config/hypr/${target_file_name}
cp -f ${dots_trg}/hyprpaper/${target_file_name} ${target_file_path}
chown ${user}:${user} ${target_file_path}
ls -al ${target_file_path}
fi