111 lines
2.4 KiB
Bash
111 lines
2.4 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
# klevstul
|
|
|
|
echo "<< 99_deploy.sh >>"
|
|
|
|
user=poq
|
|
clone_trg=/tmp
|
|
|
|
targz_dots_url=https://git.mz.fo/fro/lnx-arch/archive/master.tar.gz
|
|
dots_trg=${clone_trg}/lnx-arch/dots
|
|
|
|
targz_wp_url=https://gitlab.com/pqq/wallpaper/-/archive/main/wallpaper-main.tar.gz
|
|
wp_trg=${clone_trg}/wallpaper-main/wp
|
|
|
|
|
|
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 functions
|
|
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
|
|
|
|
}
|
|
|
|
create_dir() {
|
|
_directory=$1
|
|
|
|
mkdir -p ${_directory}
|
|
chown ${user}:${user} ${_directory}
|
|
}
|
|
|
|
deploy_file() {
|
|
_src_path=$1
|
|
_trg_path=$2
|
|
|
|
cp -f ${_src_path} ${_trg_path}
|
|
chown ${user}:${user} ${_trg_path}
|
|
|
|
file_name=$(basename ${_trg_path})
|
|
|
|
suffix=".sh"
|
|
if [[ ${file_name} == *$suffix ]]; then
|
|
chmod 755 ${_trg_path}
|
|
fi
|
|
|
|
echo ""
|
|
echo "${file_name}:"
|
|
ls -al ${_trg_path}
|
|
}
|
|
|
|
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
|
|
|
# download all dots (dot files) from repo
|
|
if [ ${operation} == "dots" ] ; then
|
|
echo "***** ${operation} *****"
|
|
download_repo ${targz_dots_url}
|
|
tree ${clone_trg}/lnx-arch
|
|
|
|
file_name=hyprland.conf
|
|
file_path=/home/${user}/.config/hypr
|
|
deploy_file ${dots_trg}/hyprland/${file_name} ${file_path}/${file_name}
|
|
|
|
file_name=hyprpaper.conf
|
|
file_path=/home/${user}/.config/hypr
|
|
deploy_file ${dots_trg}/hyprpaper/${file_name} ${file_path}/${file_name}
|
|
|
|
file_name=startup.sh
|
|
file_path=/usr/local/bin
|
|
deploy_file ${dots_trg}/startup/${file_name} ${file_path}/${file_name}
|
|
|
|
file_name=config.jsonc
|
|
file_path=/home/${user}/.config/waybar
|
|
mkdir -p ${file_path}
|
|
deploy_file "${dots_trg}/waybar/*" "${file_path}/"
|
|
|
|
fi
|
|
|
|
# download wallpapers from repo
|
|
if [ ${operation} == "wp" ] ; then
|
|
echo "***** ${operation} *****"
|
|
download_repo ${targz_wp_url}
|
|
tree ${clone_trg}/wallpaper-main
|
|
|
|
deploy_file "${wp_trg}/*" "/home/${user}/.config/hypr/"
|
|
|
|
fi
|