X-Git-Url: https://iankelling.org/git/?p=distro-setup;a=blobdiff_plain;f=brc;h=5f43270c3c9e516864451eb357515db853756764;hp=3c54796a5ce0988ae7dadaeb771bd6aa5faa1f6e;hb=3ca4714d6b02ff279a0c724415f3e0a3a6f49059;hpb=fa264ab2ec907b4ebc8d7dd0f8b239b0d0202362 diff --git a/brc b/brc index 3c54796..5f43270 100644 --- a/brc +++ b/brc @@ -2171,6 +2171,30 @@ nonet() { m() { printf "%s\n" "$*"; "$@"; } +# update file. note: duplicated in mail-setup +u() { + local tmp tmpdir dest="$1" + local base="${dest##*/}" + local dir="${dest%/*}" + if [[ $dir != "$base" ]]; then + # dest has a directory component + mkdir -p "$dir" + fi + ur=false # u result + tmpdir=$(mktemp -d) + cat >$tmpdir/"$base" + tmp=$(rsync -ic $tmpdir/"$base" "$dest") + if [[ $tmp ]]; then + printf "%s\n" "$tmp" + ur=true + if [[ $dest == /etc/systemd/system/* ]]; then + reload=true + fi + fi + rm -rf $tmpdir +} + + uptime() { if type -p uprecords &>/dev/null; then uprecords -B