From 848c07f766bc8299fe755186ee66800b1e38233b Mon Sep 17 00:00:00 2001 From: Ian Kelling Date: Tue, 4 Aug 2020 17:20:16 -0400 Subject: [PATCH] make sl easier to use --- brc | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/brc b/brc index 01c151a..fc0a683 100644 --- a/brc +++ b/brc @@ -1094,19 +1094,17 @@ sk() { # (mine are set at the beginning of this file) # SL_FILES_DIR: Environment variable. Path to folder which should at -# least have a .bashrc file or symlink. This dir will be rsynced to -# remote hosts unless the host already has a $SL_FILES_DIR/.bashrc. In -# that case, we assume it is a host you control and sync files to -# separately and already has the ~/.bashrc you want. Symlinks in this -# dir will be resolved. The directory name is important, it will be -# created on the remote host under /root. The remote bash will also take -# its .inputrc config from this folder (default of not existing is -# fine). Mine looks like this: +# least have a .bashrc file or symlink. This dir will be rsynced to ~ on +# remote hosts (top level symlinks are resolved) unless the host already +# has a $SL_FILES_DIR/.bashrc. In that case, we assume it is a host you +# control and sync files to separately and already has the ~/.bashrc you +# want. The remote bash will also take its .inputrc config from this +# folder (default of not existing is fine). Mine looks like this: # https://iankelling.org/git/?p=distro-setup;a=tree;f=sl/.iank # SL_INFO_DIR: Environment variable. This folder stores info about what -# we detected on the remote system and when we last synced. We expect it -# to exist ahead of time. Sometimes you may want to forget about a +# we detected on the remote system and when we last synced. It will be created +# if it does not exist. Sometimes you may want to forget about a # remote system, you can use sl --rsync, or the function for that slr # below. @@ -1141,6 +1139,11 @@ sl() { local now args remote dorsync haveinfo tmpa sshinfo tmp tmp2 type info_sec force_rsync sync_dirname declare -a args tmpa + if [[ ! $SL_INFO_DIR || ! $SL_FILES_DIR ]]; then + echo error: missing '$SL_' env vars >&2 + return 1 + fi + sync_dirname=${SL_FILES_DIR##*/} now=$(date +%s) @@ -1232,6 +1235,7 @@ sl() { fi if $dorsync || ! $haveinfo; then sshinfo=$SL_INFO_DIR/$now$type"$remote" + [[ -e $SL_INFO_DIR ]] || mkdir -p $SL_INFO_DIR touch $sshinfo chmod 666 $sshinfo fi -- 2.30.2