Category Archives: linux

“Commandline File Hosts”

These are the “terminal to URL” file hosts I know. Please tell me about others. The speed tests are not scientific at all, my servers might be uncapable of better speeds because of saturation or bad routing.

https://transfer.sh/

curl --upload-file "01_Name_Game_(Intro).mp3" https://transfer.sh/

Maximum Filesize: 5 Gigabytes
Expiration after: 2 weeks
Uses HTTPS!
Serves error 500 for non-existing files. Does not serve direct downloads anymore. Bleh.
Download URLs are modeled after your original filename (“special” characters are replaced): https://transfer.sh/SGNl/01-name-game-intro.mp3
1GB.zip upload: ~30-110 Megabit/s
1GB.zip download: ~240 Megabit/s

http://curl.io/

curl -F "file=@01_Name_Game_(Intro).mp3" http://curl.io/send/abcd1234

Maximum Filesize: 20 Gigabytes
Expiration after: 4 hours
Requires you to visit their website to get a key (URL) assigned.
Download URLs are random and but it serves original filename with content-disposition: http://curl.io/get/kegcxfza/85866a9bcfaf6f8eccab136238c07f659d580b25
1GB.zip upload: ~60-75 Megabit/s
1GB.zip download: 100 Megabit/s

http://chunk.io

curl --upload-file 01_Name_Game_\(Intro\).mp3 chunk.io

Maximum Filesize: 50 Megabytes
Expiration after: 6 months
They might increase filesize and expiration if there is enough interest, as of now you can not “sign-up” for those.
Download URLs are unreadable, filenames are lost: http://chunk.io/f/afb01d527ceb4d03b9bf9e62bb32263e
1GB.zip upload: ~8 Megabit/s (until it errored :) )

http://purrrl.link/
Requires sign-up.

Shutting down the operating system by playing a “kill song” in MPD

I use a 20€ Dockstar with Archlinux ARM on it as MPD music server. Since I like to turn off electronic devices when they are not needed and pulling the plug is not something you should do to running computers, I was looking for a solution to somehow shut it down from any mpd client. So I added a specific song as “shutdown file”. Once that song is played, the system will cleanly shut down and power off.

Here is the systemd .service file I came up with:

# cat /etc/systemd/system/mpdtosystemshutdown.service
[Unit]
Description=MPD to system shutdown

[Service]
ExecStart=/bin/sh -c "sleep 10 && /usr/bin/inotifywait -e open /path/to/path/music/shutdown.mp3 && mpc clear && shutdown -h now"

[Install]
WantedBy=multi-user.target

You need: inotify-tools and mpc (in addition to mpd)

  1. The service sleeps for 10 seconds in the beginning because I keep the music on an external USB harddisk which gets mounted after the multi-user target is reached. This is an ugly workaround but should be good enough. A better solution would be using a udev rule or systemd mount unit to only start the service when the harddisk is mounted.
  2. Then inotifywait will monitor shutdown.mp3 for being opened by mpd (or anything else). Once this happens inotifywait will quit successfully.
  3. mpc will clear the mpd playlist as you do not want shutdown.mp3 to be played again right after booting, do you? I surely did not.
  4. Finally the system is being shut down and powered off.

You probably have to add shutdown.mp3 to your mpd database before starting this service or the database update might trigger it. Updating the database afterwards is save and does not trigger the shutdown.

Don’t blame me if this ends up with an infinite reboot loop.