And to start up this week of various little scripts and tweaks, we’re going to collect some SSHFS tweaks and two single-use-but-damn-when-you-need-it-you-need-it scripts I wrote.
First, the subdirectory moving script: It takes every file in a directory, creates a subdirectory the same name as the filename without extension, and moves the file into that subdirectory. So, for example, ~/bob/example.txt becomes ~/bob/example/example.txt, and ~/bob/examples becomes ~/bob/examples/examples. It’s one of those things that looks like it should be a one-liner, but in order to do proper error checking (thanks for training me well, Mom!), it’s about 30 lines. It’s a gist over at https://bit.ly/2b7qVWX.
The second script is for getting placeholder images in BASH. Need a 300×300 image for some reason? Boom. There’s a node.js script that does the same sort of thing, but I wanted something simple and only requiring curl. Snag it at https://github.com/uriel1998/simple_placeholder_images.
The final thing is optimizing SSHFS. What’s nice about it is that you can mount a separate filesystem (or even parts of one) like it exists on your own hard drive without too much difficulty, and pretty transparently. I’ve been moving stuff between my main computer and the old laptop that runs Kodi pretty easily, as well as a Mac, and I’m about to set up a CHIP and a USB drive as a simple NAS without having to use OwnCloud or anything. (There’s lots of guides on how to install SSHFS at varying levels of technical difficulty and for different OS’s.)
The thing is, SSHFS can be slow. It’s meant to be secure and to compress data, but those strategies don’t make sense when you’re moving things around inside a LAN. Between this post from Admin Magazine and this one from Benjamin I discovered that this series of command line switches made a huge difference in both transfer speeds and CPU power:
Which is a hell of a lot to keep retyping, which is why I highly recommend you make the mount and unmount commands into bash aliases. 🙂
Note: If you get "connection reset by peer" after this, follow the instructions at https://mgalgs.github.io/2014/10/22/enable-arcfour-and-other-fast-ciphers-on-recent-versions-of-openssh.html to make it work.