• Author Owner

    2024-06-12: An interesting idea which I considered back in 2019 was to automatically slurp dotfiles to SSH hosts when connecting.

    That method was to use tar to pack and unpack a list of files from the local machine into the remote.

    It would be interesting now to use yadm to install the dotfiles on the remote, using my install snippet but executed via SSH, something like:

    Host *
      PermitLocalCommand yes 
      LocalCommand \
        curl -fsSL \
          https://gitlab.com/milohax-net/radix/dotfiles/-/snippets/3705626/raw/main/install.sh \
            | ssh -o PermitLocalCommand=no %n "bash"

    The install script would need to be smart enough not to install again if it's already done.

  • Author Owner

    I considered using compression in the slurp. The file produced would be smaller:

    ~► tar cfz tarball ~/tmp/get-*; ls -l tarball
    tar: Removing leading '/' from member names
    .rw-r--r-- mjl staff 531 B Thu Jun 13 10:03:18 2024  tarball

    But I'd have to work out what I'm doing wrong wrong because simply changing cat to tar cz makes it twelve times larger:

    ~► cat ~/tmp/get-*|wc
          20      68     805
    ~► tar cz ~/tmp/get-*|wc
    tar: Removing leading '/' from member names
           2      14   10240

    Alternatively, I could shorten the URLs in both snippets, to reduce the 805 bytes, but I'd rather send them raw, than break it if I lose my DNS domain.

    I think for a potential 805 - 531 = 274 bytes saved for each SSH connection, it's not worth the effort or complexity.

  • Author Owner

    TODO: Include fishing into dotfiles-slurp.sh.

    testd -d ~/lib/fish \
      || git clone git@gitlab.com:milohax-net/radix/fishing.git ~/lib/fish
    test -s ~/.config/fish \
      || rm -rf ~/.config/fish; ln -s ~/lib/fish ~/.config.fish
  • Author Owner

    dotfiles-slurp.sh is also available via a shortened URL:

    https://milohax.net/slurp

    i.e. one can get the bootstrap slurp script like so:

    	LocalCommand  curl -fsSL https://milohax.net/slurp | bash | ssh -o PermitLocalCommand=no %n bash

    I don't know if that's better or not? But if not SSH-slurping, it probably is better:

    curl -fsSL https://milohax.net/slurp | bash | bash
  • Author Owner

    TODO: Include bash in the list of basic programs.

    • Requires that the basic.sh be rewritten for POSIX (remove bash-isms)
    • bash-ism: redirect all streams with &> /dev/null. replace with > /dev/null 2>&1
    • bash-ism: testing with [[ -n ${PKGR} ]] ||, replace with test -d ${PKGR} ||
    • bash-ism: arrays. POSIX shell doesn't have first-class arrays. Read https://www.baeldung.com/linux/posix-shell-array
    • bash-ism: functions. POSIX shell doesn't have functions! Probably the simplest fix is to just repeat the type calls.

    All of these are good arguments to make sure there is bash everywhere I go! It's missing in Alpine. These are also all good arguments for this basic.sh script to not be slurped during SSH connection, because it's going to be a lot longer.

    2024-06-27T21:23Z - For the array issue, I'll have a read of that article, but probably I will just install everything in one go and let the package managers skip already installed packages.

    2024-07-29T00:11Z - I have tried with boot.sh to get this to run in Alpine. It works (with cut/paste) and will install bash/git/curl, and then install yadm/dotfiles/bashing. But, on trying to run bash, it fails because the version of grep in Alpine is based on BusyBox, and does not understand GNU switches like --quiet. If feel that for Alpine, it is not worth it to refactor my bashing library to work with BusyBox utilities. So, I think I will abandon this approach, for Alpine at least. The dotfiles are useful though, if I install the utilities into Alpine that I want.

    2024-07-30T10:10Z - The Alpine grep package installs a version of grep which understands --quiet 👍 Added it to the list of packages in apk installs, and now Bashing will load

    2024-07-11T23:43Z - Technically grep, and hostname are needed by Bashing and not Bootstrap. I'm installing them here for Alpine and SUSE because it smells less than repeating the package install in Bashing's bootstrap snippet

    Edited by Mike Lockhart | GitLab
  • Author Owner

    TODO: refactor dotfiles-slurp.sh

    • have boot.sh which tests and installs basic and then curls/clones the others, like dotfiles-slurp.sh
    • would reduce the SSH paylod to something like curl -fsSL https://gitlab.com/milohax-net/radix/bootstrap/-/snippets/3721686/raw/main/boot.sh (94 bytes, instead of 1194).

    0224-07-29T09:07Z - Well, it's more than 94 bytes, but one cannot curl if that's not installed. So now boot.sh is a combination of the dotfiles-slurp.sh and basic.sh logic, rewritten for /bin/sh, with less logic and with shortened URLs using this project's .gitlab.io domain. I don't know if this is "perfection", but Antoine de Saint-Exupéry would still be pleased, I think.

    Edited by MikeL
  • Author Owner

    You can also use this boot.sh without SSH by copy/paste, for example:

    curl -fsSL https://milohax.net/profile.sub | pbcopy
    nerdctl run -it --rm rockylinux:9.3
    cat > profile.sub

    (then paste)

    cat profile.sub | sh

    (profile.sub is just a name I chose because PROFILE.SUB was the startup submit file for CP/M+ back in the 1980s. I recall spending a bit of time playing with that as a kid, making my little Amstrad CPC's CP/M+ bootstrap be more like a Hollywood mainframe)

    Edited by MikeL
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment