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
|
|
|
|
|
|
|
|
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-05-11 20:00:35 -05:00
|
|
|
options_url=https://git.mz.fo/fro/lnx-arch/raw/branch/master/dots/archinstall/${HOSTNAME}/options.sh
|
|
|
|
|
options_trg=/tmp/options.sh
|
|
|
|
|
rm -rf ${options_trg}
|
|
|
|
|
rm -rf ${options_trg}.tmp
|
|
|
|
|
wget -q ${options_url} -O ${options_trg}
|
|
|
|
|
source ${options_trg}
|
2024-05-11 19:42:05 -05:00
|
|
|
if [ -z "${OPTIONS_LOADED}" ]; then
|
|
|
|
|
echo "error: unable to load options"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
user=${USER}
|
2024-05-11 20:06:23 -05:00
|
|
|
clone_trg=${CLONE_TARGET_DIR}
|
2024-05-11 19:42:05 -05:00
|
|
|
|
2024-04-30 07:40:24 -05:00
|
|
|
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
|
|
|
|
|
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-05-15 07:30:46 -05:00
|
|
|
_recursive=$4
|
2024-04-30 21:01:05 -05:00
|
|
|
|
2024-05-15 17:10:45 -05:00
|
|
|
file_name_src=$(basename ${_src_path})
|
|
|
|
|
file_name_trg=$(basename ${_trg_path})
|
2024-05-04 17:11:11 -05:00
|
|
|
echo ""
|
2024-05-15 17:10:45 -05:00
|
|
|
echo "${file_name_trg}:"
|
2024-05-04 17:11:11 -05:00
|
|
|
|
2024-05-15 17:00:57 -05:00
|
|
|
suffix=".zip"
|
2024-05-15 17:10:45 -05:00
|
|
|
if [[ ${file_name_src} == *$suffix ]] ; then
|
2024-05-15 17:00:57 -05:00
|
|
|
unzip ${_src_path} -d ${_trg_path}
|
|
|
|
|
else
|
|
|
|
|
# -f (--force): overwrite without confirmation
|
|
|
|
|
cp --force --recursive ${_src_path} ${_trg_path}
|
|
|
|
|
fi
|
2024-04-30 21:14:23 -05:00
|
|
|
|
2024-05-03 12:54:11 -05:00
|
|
|
# only chown if _no_chown variable is empty
|
2024-05-15 07:30:46 -05:00
|
|
|
if [[ ${_no_chown} != "no_chown" ]] ; then
|
2024-05-09 20:07:59 -05:00
|
|
|
# if the target path ends with a slash, we have a directory
|
2024-05-09 20:03:27 -05:00
|
|
|
if [[ "$_trg_path" == */ ]]
|
|
|
|
|
then
|
2024-05-09 20:40:02 -05:00
|
|
|
echo "(ignore potential \"chown: cannot access\" error, which will occur if there are no dot-files in the directory)"
|
2024-05-15 07:30:46 -05:00
|
|
|
|
|
|
|
|
if [[ ${_recursive} != "recursive" ]] ; then
|
|
|
|
|
# https://serverfault.com/questions/156437/how-to-chown-a-directory-recursively-including-hidden-files-or-directories
|
2024-05-15 07:33:25 -05:00
|
|
|
chown ${user}:${user} ${_trg_path}*
|
|
|
|
|
chown ${user}:${user} ${_trg_path}.[^.]*
|
2024-05-15 07:30:46 -05:00
|
|
|
else
|
2024-05-15 07:33:25 -05:00
|
|
|
chown -R ${user}:${user} ${_trg_path}*
|
|
|
|
|
chown -R ${user}:${user} ${_trg_path}.[^.]*
|
2024-05-15 07:30:46 -05:00
|
|
|
fi
|
2024-05-09 20:07:59 -05:00
|
|
|
else
|
|
|
|
|
chown ${user}:${user} ${_trg_path}
|
2024-05-09 20:03:27 -05:00
|
|
|
fi
|
2024-05-03 12:54:11 -05:00
|
|
|
fi
|
2024-04-30 21:49:15 -05:00
|
|
|
|
2024-04-30 21:52:09 -05:00
|
|
|
suffix=".sh"
|
2024-05-15 17:10:45 -05:00
|
|
|
if [[ ${file_name_trg} == *$suffix ]] ; then
|
2024-05-11 22:23:14 -05:00
|
|
|
chmod 755 ${_trg_path}/*.sh
|
2024-05-15 17:10:45 -05:00
|
|
|
elif [[ ${file_name_trg} == "bin" ]] ; then
|
2024-05-11 22:24:25 -05:00
|
|
|
chmod 755 ${_trg_path}/*
|
2024-04-30 21:52:09 -05:00
|
|
|
fi
|
|
|
|
|
|
2024-04-30 21:01:05 -05:00
|
|
|
ls -al ${_trg_path}
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-12 14:14:13 -05:00
|
|
|
# locate firefox's profile directory
|
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-05-04 16:20:52 -05:00
|
|
|
# declarations
|
|
|
|
|
targz_dots_url=https://git.mz.fo/fro/lnx-arch/archive/master.tar.gz
|
|
|
|
|
dots_trg=${clone_trg}/lnx-arch/dots
|
|
|
|
|
|
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-04 13:32:09 -05:00
|
|
|
# ----------
|
|
|
|
|
# system
|
|
|
|
|
# ----------
|
|
|
|
|
|
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-04 13:32:09 -05:00
|
|
|
# ----------
|
|
|
|
|
# programs
|
|
|
|
|
# ----------
|
|
|
|
|
|
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-04 17:08:00 -05:00
|
|
|
file_name=user.js
|
2024-05-03 16:04:58 -05:00
|
|
|
file_path=${ffpd}
|
|
|
|
|
deploy_file "${dots_trg}/firefox/${file_name}" "${file_path}/${file_name}"
|
|
|
|
|
|
|
|
|
|
file_name=userChrome.css
|
|
|
|
|
file_path=${ffpd}/chrome
|
2024-05-04 17:20:50 -05:00
|
|
|
mkdir -p ${file_path}
|
2024-05-03 16:04:58 -05:00
|
|
|
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-15 13:10:49 -05:00
|
|
|
# gtk (upd using lxappearance)
|
2024-05-15 13:01:55 -05:00
|
|
|
file_name=settings.ini
|
|
|
|
|
file_path=/home/${user}/.config/gtk-3.0
|
|
|
|
|
mkdir -p ${file_path}
|
|
|
|
|
deploy_file "${dots_trg}/gtk/${file_name}" "${file_path}/${file_name}"
|
|
|
|
|
|
2024-05-15 06:54:28 -05:00
|
|
|
# pcmanfm
|
|
|
|
|
file_name=pcmanfm.conf
|
|
|
|
|
file_path=/home/${user}/.config/pcmanfm/default
|
|
|
|
|
mkdir -p ${file_path}
|
|
|
|
|
deploy_file "${dots_trg}/vscodium/${file_name}" "${file_path}/${file_name}"
|
|
|
|
|
|
2024-05-14 08:56:48 -05:00
|
|
|
# vscodium
|
|
|
|
|
file_name=settings.json
|
2024-05-14 17:40:18 -05:00
|
|
|
file_path=/home/${user}/.config/VSCodium/User
|
2024-05-14 08:58:52 -05:00
|
|
|
mkdir -p ${file_path}
|
2024-05-14 08:56:48 -05:00
|
|
|
deploy_file "${dots_trg}/vscodium/${file_name}" "${file_path}/${file_name}"
|
|
|
|
|
|
2024-05-11 20:47:34 -05:00
|
|
|
# i3wm
|
2024-05-11 20:12:01 -05:00
|
|
|
if [ ${I3WM} == "true" ] ; then
|
2024-05-11 20:47:34 -05:00
|
|
|
|
|
|
|
|
# i3
|
|
|
|
|
file_name=config
|
|
|
|
|
file_path=/home/${user}/.config/i3
|
|
|
|
|
mkdir -p ${file_path}
|
2024-05-11 21:14:05 -05:00
|
|
|
deploy_file "${dots_trg}/i3wm/${file_name}" "${file_path}/"
|
2024-05-11 20:47:34 -05:00
|
|
|
|
2024-05-11 20:12:01 -05:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ ${I3WM} == "true" ] || [ ${QTILE} == "true" ] ; then
|
|
|
|
|
|
|
|
|
|
# xorg
|
|
|
|
|
file_path=/home/${user}
|
|
|
|
|
deploy_file "${dots_trg}/xorg/.*" "${file_path}/"
|
|
|
|
|
|
|
|
|
|
fi
|
2024-05-09 19:41:43 -05:00
|
|
|
|
2024-04-30 20:41:12 -05:00
|
|
|
fi
|
|
|
|
|
|
2024-05-04 15:17:19 -05:00
|
|
|
# dots+ (wallpapers, fonts ++)
|
|
|
|
|
if [ ${operation} == "dots+" ] ; then
|
2024-05-01 11:15:00 -05:00
|
|
|
|
2024-05-04 16:20:52 -05:00
|
|
|
# declarations
|
|
|
|
|
targz_dotsplus_url=https://gitlab.com/pqq/dotsplus/-/archive/main/dotsplus-main.tar.gz
|
|
|
|
|
dotsplus_trg=${clone_trg}/dotsplus-main
|
|
|
|
|
|
2024-04-30 20:41:12 -05:00
|
|
|
echo "***** ${operation} *****"
|
2024-05-04 16:20:52 -05:00
|
|
|
rm -rf ${dotsplus_trg}
|
2024-05-04 13:59:42 -05:00
|
|
|
download_repo ${targz_dotsplus_url}
|
2024-05-04 16:20:52 -05:00
|
|
|
tree ${clone_trg}
|
2024-05-04 13:59:42 -05:00
|
|
|
|
|
|
|
|
# ----------
|
|
|
|
|
# fonts
|
|
|
|
|
# ----------
|
|
|
|
|
file_path=/home/${user}/.local/share/fonts
|
|
|
|
|
mkdir -p ${file_path}
|
2024-05-04 15:23:28 -05:00
|
|
|
deploy_file "${dotsplus_trg}/fonts/install/*" "${file_path}/"
|
2024-05-04 13:59:42 -05:00
|
|
|
|
|
|
|
|
# ----------
|
|
|
|
|
# wallpapers
|
|
|
|
|
# ----------
|
2024-05-11 21:18:27 -05:00
|
|
|
file_path=/home/${user}/.local/share/wp
|
|
|
|
|
mkdir -p ${file_path}
|
|
|
|
|
deploy_file "${dotsplus_trg}/wallpapers/install/*" "${file_path}/"
|
2024-04-30 21:06:41 -05:00
|
|
|
|
2024-05-15 07:37:55 -05:00
|
|
|
# ----------
|
|
|
|
|
# miscelanneous
|
|
|
|
|
# ----------
|
|
|
|
|
|
|
|
|
|
# vscodium theme
|
|
|
|
|
# https://vscodethemes.com/e/sdras.night-owl/night-owl-no-italics?language=javascript
|
|
|
|
|
# https://github.com/sdras/night-owl-vscode-theme/tree/main/themes
|
2024-05-15 17:13:52 -05:00
|
|
|
file_name=night-owl-vscode-theme-main.zip
|
2024-05-15 07:37:55 -05:00
|
|
|
file_path=/home/${user}/.vscode-oss/extensions
|
|
|
|
|
mkdir -p ${file_path}
|
|
|
|
|
deploy_file "${dotsplus_trg}/miscellaneous/${file_name}" "${file_path}/" chown recursive
|
|
|
|
|
|
2024-05-15 17:00:57 -05:00
|
|
|
# sweet dark gtk theme
|
|
|
|
|
# https://github.com/EliverLara/Sweet
|
|
|
|
|
# https://github.com/EliverLara/Sweet/releases
|
|
|
|
|
file_name=Sweet-Dark.zip
|
|
|
|
|
file_path=/usr/share/themes
|
|
|
|
|
deploy_file "${dotsplus_trg}/miscellaneous/${file_name}" "${file_path}/" chown recursive
|
2024-05-15 07:37:55 -05:00
|
|
|
|
2024-04-30 07:40:24 -05:00
|
|
|
fi
|