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-05-03 12:54:11 -05:00
|
|
|
_no_chown=$3
|
2024-04-30 21:01:05 -05:00
|
|
|
|
2024-04-30 21:13:08 -05:00
|
|
|
cp -f ${_src_path} ${_trg_path}
|
2024-04-30 21:14:23 -05:00
|
|
|
|
2024-05-03 12:54:11 -05:00
|
|
|
# only chown if _no_chown variable is empty
|
|
|
|
|
if [ -z "${_no_chown}" ]; then
|
|
|
|
|
chown ${user}:${user} ${_trg_path}
|
|
|
|
|
fi
|
2024-04-30 21:49:15 -05:00
|
|
|
|
2024-05-03 12:54:11 -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-05-03 16:14:26 -05:00
|
|
|
# locate profile folder
|
2024-05-03 15:42:24 -05:00
|
|
|
firefox_profile_dir() {
|
2024-05-03 15:46:20 -05:00
|
|
|
ffdir=/home/${user}/.mozilla/firefox/
|
2024-05-03 15:50:14 -05:00
|
|
|
|
2024-05-03 15:51:45 -05:00
|
|
|
if ! [ -d "$ffdir" ]
|
2024-05-03 15:42:24 -05:00
|
|
|
then
|
2024-05-03 16:03:41 -05:00
|
|
|
echo "error: firefox main directory not found: '${ffdir}'"
|
2024-05-03 15:42:24 -05:00
|
|
|
else
|
2024-05-03 15:50:14 -05:00
|
|
|
pattern=".default-release"
|
|
|
|
|
old_dir=`pwd`
|
|
|
|
|
cd ${ffdir}
|
|
|
|
|
for _dir in *"${pattern}"*; do
|
|
|
|
|
[ -d "${_dir}" ] && dir="${_dir}" && break
|
|
|
|
|
done
|
|
|
|
|
cd ${old_dir}
|
|
|
|
|
|
|
|
|
|
if [ -z "$dir" ]
|
|
|
|
|
then
|
2024-05-03 16:02:00 -05:00
|
|
|
echo "error: firefox profile directory not found"
|
2024-05-03 15:50:14 -05:00
|
|
|
else
|
|
|
|
|
ffprofiledir=${ffdir}${dir}
|
|
|
|
|
echo "${ffprofiledir}"
|
|
|
|
|
fi
|
2024-05-03 15:42:24 -05:00
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-30 22:02:09 -05:00
|
|
|
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
2024-04-30 07:40:24 -05:00
|
|
|
|
2024-05-01 11:15:00 -05:00
|
|
|
# dots (dot files)
|
2024-04-30 20:29:46 -05:00
|
|
|
if [ ${operation} == "dots" ] ; then
|
2024-05-01 11:15:00 -05:00
|
|
|
|
2024-04-30 07:40:24 -05:00
|
|
|
echo "***** ${operation} *****"
|
2024-05-01 11:08:34 -05:00
|
|
|
rm -rf ${clone_trg}/lnx-arch
|
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-05-03 13:52:41 -05:00
|
|
|
# bashrc
|
|
|
|
|
file_name=.bashrc
|
|
|
|
|
file_path=/home/${user}
|
|
|
|
|
deploy_file "${dots_trg}/bash/${file_name}" "${file_path}/${file_name}"
|
|
|
|
|
|
2024-05-03 12:54:11 -05:00
|
|
|
# bin (executable binaries, scripts)
|
|
|
|
|
file_path=/usr/local/bin
|
2024-05-03 14:02:20 -05:00
|
|
|
deploy_file "${dots_trg}/bin/*" "${file_path}/"
|
2024-05-03 12:54:11 -05:00
|
|
|
|
2024-05-03 13:01:11 -05:00
|
|
|
# environment
|
2024-05-03 13:02:07 -05:00
|
|
|
file_name=environment
|
2024-05-03 13:01:11 -05:00
|
|
|
file_path=/etc
|
2024-05-03 13:02:07 -05:00
|
|
|
deploy_file "${dots_trg}/environment/${file_name}" "${file_path}/${file_name}" no_chown
|
|
|
|
|
|
2024-05-03 15:42:24 -05:00
|
|
|
# firefox
|
|
|
|
|
file_name=policies.json
|
|
|
|
|
file_path=/usr/lib/firefox/distribution
|
2024-05-03 16:06:21 -05:00
|
|
|
deploy_file "${dots_trg}/firefox/${file_name}" "${file_path}/${file_name}" no_chown
|
2024-05-03 15:42:24 -05:00
|
|
|
|
2024-05-03 15:58:29 -05:00
|
|
|
ffpd=$(firefox_profile_dir)
|
2024-05-03 16:04:14 -05:00
|
|
|
if [[ ${ffpd} == error* ]] ; then
|
2024-05-03 16:02:00 -05:00
|
|
|
echo ${ffpd}
|
|
|
|
|
else
|
2024-05-03 16:04:58 -05:00
|
|
|
file_name=user.json
|
|
|
|
|
file_path=${ffpd}
|
|
|
|
|
deploy_file "${dots_trg}/firefox/${file_name}" "${file_path}/${file_name}"
|
|
|
|
|
|
|
|
|
|
file_name=userChrome.css
|
|
|
|
|
file_path=${ffpd}/chrome
|
|
|
|
|
deploy_file "${dots_trg}/firefox/${file_name}" "${file_path}/${file_name}"
|
2024-05-03 16:02:00 -05:00
|
|
|
fi
|
2024-05-03 15:42:24 -05:00
|
|
|
|
2024-05-03 13:18:08 -05:00
|
|
|
# hypridle
|
|
|
|
|
file_name=hypridle.conf
|
|
|
|
|
file_path=/home/${user}/.config/hypr
|
|
|
|
|
deploy_file ${dots_trg}/hypridle/${file_name} ${file_path}/${file_name}
|
|
|
|
|
|
|
|
|
|
# hyprland
|
|
|
|
|
file_name=hyprland.conf
|
|
|
|
|
file_path=/home/${user}/.config/hypr
|
|
|
|
|
deploy_file ${dots_trg}/hyprland/${file_name} ${file_path}/${file_name}
|
|
|
|
|
|
|
|
|
|
# hyprpaper
|
|
|
|
|
file_name=hyprpaper.conf
|
|
|
|
|
file_path=/home/${user}/.config/hypr
|
|
|
|
|
deploy_file ${dots_trg}/hyprpaper/${file_name} ${file_path}/${file_name}
|
|
|
|
|
|
|
|
|
|
# waybar
|
|
|
|
|
file_path=/home/${user}/.config/waybar
|
|
|
|
|
mkdir -p ${file_path}
|
|
|
|
|
deploy_file "${dots_trg}/waybar/*" "${file_path}/"
|
2024-04-30 21:26:27 -05:00
|
|
|
|
2024-04-30 20:41:12 -05:00
|
|
|
fi
|
|
|
|
|
|
2024-05-01 11:15:00 -05:00
|
|
|
# wallpapers
|
2024-04-30 20:41:12 -05:00
|
|
|
if [ ${operation} == "wp" ] ; then
|
2024-05-01 11:15:00 -05:00
|
|
|
|
2024-04-30 20:41:12 -05:00
|
|
|
echo "***** ${operation} *****"
|
2024-05-01 11:08:34 -05:00
|
|
|
rm -rf ${clone_trg}/wallpaper-main
|
2024-04-30 20:41:12 -05:00
|
|
|
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
|