From 7d000c5e473e9a5f89bc242f3d7b36e0ee9008f9 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Tue, 16 Jan 2024 23:28:32 -0800 Subject: [PATCH] a --- create-links | 4 +++- scripts/my-fetch-repos | 39 +++++++++++++++++++++++++++++++++++++ systemd-fetch-repos.service | 5 +++++ systemd-fetch-repos.timer | 9 +++++++++ 4 files changed, 56 insertions(+), 1 deletion(-) create mode 100755 scripts/my-fetch-repos create mode 100644 systemd-fetch-repos.service create mode 100644 systemd-fetch-repos.timer diff --git a/create-links b/create-links index 97f4470..a5febe9 100755 --- a/create-links +++ b/create-links @@ -41,8 +41,8 @@ install "gdbinit" ".config/gdb/gdbinit" install "gitconfig" ".config/git/config" touch "$dst_base/.config/git/credentials" install "i3status-config" ".config/i3status/config" -install "msmtprc" ".config/msmtp/config" install "msmtp-aliases" ".config/msmtp/aliases" +install "msmtprc" ".config/msmtp/config" install "sh-aliases.sh" ".config/sh/aliases.sh" install "sh-paths.sh" ".config/sh/paths.sh" install "sh-rc.sh" ".config/sh/rc.sh" @@ -52,6 +52,8 @@ install "ssh-config" ".ssh/config" install "sway-config" ".config/sway/config" install "sway-session" ".local/bin/sway-session" install "sway-session-autostart" ".local/bin/sway-session-autostart" +install "systemd-fetch-repos.service" ".config/systemd/user/fetch-repos.service" +install "systemd-fetch-repos.timer" ".config/systemd/user/fetch-repos.timer" install "tmux.conf" ".config/tmux/tmux.conf" install "vimrc" ".vim/vimrc" install "vim-pack" ".vim/pack" diff --git a/scripts/my-fetch-repos b/scripts/my-fetch-repos new file mode 100755 index 0000000..7d44870 --- /dev/null +++ b/scripts/my-fetch-repos @@ -0,0 +1,39 @@ +#!/bin/sh + +git_repos=" + chromiumos + chromiumos/chromium/src + projects/linux +" +fetched_repos="" +failed_repos="" + +for repo in $git_repos; do + echo "fetching $repo..." + + path="$HOME/$repo" + if [ -d "$path/.git" ]; then + cd "$path" + if git fetch --prune --all; then + fetched_repos="$fetched_repos $repo" + else + failed_repos="$failed_repos $repo" + fi + elif [ -d "$path/.repo" ]; then + cd "$path" + if ./depot_tools/repo sync -j8 -n; then + fetched_repos="$fetched_repos $repo" + else + failed_repos="$failed_repos $repo" + fi + else + failed_repos="$failed_repos $repo" + fi +done + +if [ -n "$fetched_repos" ]; then + echo "fetched repos:$fetched_repos" +fi +if [ -n "$failed_repos" ]; then + echo "failed repos:$failed_repos" +fi diff --git a/systemd-fetch-repos.service b/systemd-fetch-repos.service new file mode 100644 index 0000000..54935cc --- /dev/null +++ b/systemd-fetch-repos.service @@ -0,0 +1,5 @@ +[Unit] +Description=Fetch my repos + +[Service] +ExecStart=%h/olv-etc/scripts/my-fetch-repos diff --git a/systemd-fetch-repos.timer b/systemd-fetch-repos.timer new file mode 100644 index 0000000..d48ee94 --- /dev/null +++ b/systemd-fetch-repos.timer @@ -0,0 +1,9 @@ +[Unit] +Description=Fetch my repos periodically + +[Timer] +OnStartupSec=30s +OnUnitActiveSec=4h + +[Install] +WantedBy=timers.target