aboutsummaryrefslogtreecommitdiffstats
path: root/.local/bin/fossil-update
diff options
context:
space:
mode:
authorla-ninpre <leobrekalini@gmail.com>2021-07-12 16:27:52 +0300
committerla-ninpre <leobrekalini@gmail.com>2021-07-12 16:27:52 +0300
commite3bbee81de559c1b4dea7a83d46da3b4e00cc2a8 (patch)
tree697bca3add8a534bd6ed6a82308ef5869cc78393 /.local/bin/fossil-update
parent2d5fa70da78d05147a4055c51c983b93a4bc32dd (diff)
downloaddotfiles-e3bbee81de559c1b4dea7a83d46da3b4e00cc2a8.tar.gz
dotfiles-e3bbee81de559c1b4dea7a83d46da3b4e00cc2a8.zip
move to GNU stow approach on managing dotfiles
Diffstat (limited to '.local/bin/fossil-update')
-rwxr-xr-x.local/bin/fossil-update95
1 files changed, 0 insertions, 95 deletions
diff --git a/.local/bin/fossil-update b/.local/bin/fossil-update
deleted file mode 100755
index 5ea4d1e..0000000
--- a/.local/bin/fossil-update
+++ /dev/null
@@ -1,95 +0,0 @@
-#!/bin/sh
-
-SUDO=doas
-_fossil_co=$(fossil all ls -c | grep fossil) # fossil checkout location
-_ask_upgrade=1
-_ask_all=1
-_clean_build=0
-_make_jobs=8
-
-usage() {
- echo "usage: fossil-update [OPTIONS]"
- echo "options:"
- echo " -y upgrade without asking"
- echo " -a upgrade and turn off the fossil service(if it's running) without asking"
- echo " -c clean build, run 'make distclean' before building"
- echo " -h print this help message"
-}
-
-check_service() {
- _fsl_pid=$(pgrep -u root -f "$(which fossil)") && export _fsl_pid
- [ -n "$_fsl_pid" ] && {
- [ "$_ask_all" -ne 0 ] && {
- echo "fossil service is active. stop it? (Y/y)"
- read -r _stop_fsl
- case $_stop_fsl in
- [Yy] ) stop_service && return 0
- ;;
- * ) echo "upgrade is not possible" && exit 2
- ;;
- esac
- }
- stop_service
- }
-}
-
-stop_service() {
- # i am using systemd service to run fossil server
- $SUDO systemctl stop fossil
-}
-
-compile() {
- echo "configuring..." && \
- ./configure >/dev/null && \
- echo "building..." && make -j "$_make_jobs" >/dev/null \
- && echo "build done"
-}
-
-install() {
- check_service
- $SUDO make install >/dev/null && echo "upgrade done"
- [ -n "$_fsl_pid" ] && echo "don't forget to enable fossil service back" \
- || return 0
-}
-
-main() {
- cd "$_fossil_co" || return
- [ $_clean_build -gt 0 ] && {
- echo "cleaning previous build"
- [ -f Makefile ] && make distclean >/dev/null
- }
- fossil up trunk
- [ $_ask_all -eq 0 ] || [ $_ask_upgrade -eq 0 ] && {
- compile && install
- exit
- }
- echo "upgrade? (Y/y)" && \
- read -r _upgrade && \
- case $_upgrade in
- [Yy] ) compile && install
- ;;
- * ) exit 1
- ;;
- esac
-}
-
-while getopts yach opts
-do
- case "$opts" in
- y)
- _ask_upgrade=0
- ;;
- a)
- _ask_all=0
- ;;
- c)
- _clean_build=1
- ;;
- h|*)
- usage && exit 1
- ;;
- esac
-done
-
-main
-