Files
lnx-arch/scripts/99_deploy.sh

103 lines
2.2 KiB
Bash
Raw Normal View History

2024-04-30 07:40:24 -05:00
#!/usr/bin/env bash
# klevstul
2024-04-30 21:34:49 -05:00
echo "<< 99_deploy.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
2024-04-30 21:06:41 -05:00
wp_trg=${clone_trg}/wallpaper-main/wp
2024-04-30 20:41:12 -05:00
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
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
2024-04-30 21:01:05 -05:00
# helper functions
2024-04-30 07:40:24 -05:00
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
}
2024-04-30 21:44:25 -05:00
create_dir() {
_directory=$1
mkdir -p ${_directory}
chown ${user}:${user} ${_directory}
}
2024-04-30 21:01:05 -05:00
deploy_file() {
_src_path=$1
_trg_path=$2
2024-04-30 21:13:08 -05:00
cp -f ${_src_path} ${_trg_path}
chown ${user}:${user} ${_trg_path}
2024-04-30 21:14:23 -05:00
2024-04-30 21:49:15 -05:00
file_name=$(basename ${_trg_path})
2024-04-30 21:52:09 -05:00
suffix=".sh"
if [[ ${file_name} == *$suffix ]]; then
chmod 755 ${_trg_path}
fi
2024-04-30 21:16:01 -05:00
echo ""
2024-04-30 21:49:15 -05:00
echo "${file_name}:"
2024-04-30 21:01:05 -05:00
ls -al ${_trg_path}
}
2024-04-30 07:40:24 -05:00
# 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
2024-04-30 21:01:05 -05:00
file_name=hyprland.conf
deploy_file ${dots_trg}/hyprland/${file_name} /home/${user}/.config/hypr/${file_name}
2024-04-30 07:40:24 -05:00
2024-04-30 21:01:05 -05:00
file_name=hyprpaper.conf
2024-04-30 21:04:02 -05:00
deploy_file ${dots_trg}/hyprpaper/${file_name} /home/${user}/.config/hypr/${file_name}
2024-04-30 07:40:24 -05:00
2024-04-30 21:26:27 -05:00
file_name=startup.sh
2024-04-30 21:55:19 -05:00
deploy_file ${dots_trg}/startup/${file_name} /usr/local/bin/${file_name}
2024-04-30 21:26:27 -05:00
2024-04-30 20:41:12 -05:00
fi
# download wallpapers from repo
if [ ${operation} == "wp" ] ; then
echo "***** ${operation} *****"
download_repo ${targz_wp_url}
2024-04-30 20:42:42 -05:00
tree ${clone_trg}/wallpaper-main
2024-04-30 07:40:24 -05:00
2024-04-30 21:12:00 -05:00
deploy_file "${wp_trg}/*" "/home/${user}/.config/hypr/"
2024-04-30 21:06:41 -05:00
2024-04-30 07:40:24 -05:00
fi