Files
lnx-arch/scripts/99_download.sh

78 lines
1.8 KiB
Bash
Raw Normal View History

2024-04-30 07:40:24 -05:00
#!/usr/bin/env bash
# klevstul
2024-04-30 20:29:46 -05:00
echo "<< 99_download.sh >>"
2024-04-30 07:40:24 -05:00
user=poq
clone_trg=/tmp
2024-04-30 20:41:12 -05:00
targz_dots_url=https://git.mz.fo/fro/lnx-arch/archive/master.tar.gz
2024-04-30 07:40:24 -05:00
dots_trg=${clone_trg}/lnx-arch/dots
2024-04-30 20:41:12 -05:00
targz_wp_url=https://gitlab.com/pqq/wallpaper/-/archive/main/wallpaper-main.tar.gz
wp_trg=${clone_trg}/lnx-arch/dots
2024-04-30 07:40:24 -05:00
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() {
2024-04-30 20:29:46 -05:00
_targz_url=$1
2024-04-30 07:40:24 -05:00
# 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.
2024-04-30 20:29:46 -05:00
wget --show-progress ${_targz_url} -O ${clone_trg}/tmp.tar.gz
2024-04-30 07:40:24 -05:00
tar -xzf ${clone_trg}/tmp.tar.gz -C ${clone_trg}
rm ${clone_trg}/tmp.tar.gz
}
# download all dots (dot files) from repo
2024-04-30 20:29:46 -05:00
if [ ${operation} == "dots" ] ; then
2024-04-30 07:40:24 -05:00
echo "***** ${operation} *****"
2024-04-30 20:34:33 -05:00
download_repo ${targz_dots_url}
2024-04-30 07:40:24 -05:00
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}
2024-04-30 20:41:12 -05:00
fi
2024-04-30 07:40:24 -05:00
2024-04-30 20:41:12 -05:00
# download wallpapers from repo
if [ ${operation} == "wp" ] ; then
echo "***** ${operation} *****"
download_repo ${targz_wp_url}
2024-04-30 20:42:04 -05:00
tree ${clone_trg}/wallpaper
2024-04-30 07:40:24 -05:00
fi