๐Ÿ“ฆโž”๐Ÿฆ‹ Store and retrieve files on the Atmosphere
35
fork

Configure Feed

Select the types of activity you want to include in your feed.

various

Ducky d424ada5 2e322460

+154 -63
+4 -7
README.md
··· 27 27 * ๐ŸŸข **macOS**: Compatible with built-in version of Bash (3.2) 28 28 * ๐ŸŸก **Windows**: MinGW (Cygwin, Git Bash, MSYS2, etc.) and WSL (see Linux caveats above) 29 29 * This repository **does not** provide a native version for Windows 30 - * ๐ŸŸข **BSD**: FreeBSD, NetBSD and OpenBSD; other non-detected BSDs should work (see ยน) 30 + * ๐ŸŸข __*BSD__: FreeBSD, NetBSD, OpenBSD, and other *BSD's 31 31 * ๐ŸŸข **Haiku**: [Yes, really](https://bsky.app/profile/did:plc:kv7sv4lynbv5s6gdhn5r5vcw/post/3lboqznyqgs26) 32 32 * ๐Ÿ”ด **Solaris**: <span title="Don't we all?">Has issues</span>; low priority 33 33 * **Bashยณ:** 3.x or later ··· 43 43 * [`websocat`](https://github.com/vi/websocat) _(optional: needed for `stream`)_ 44 44 * **ATProto account** 45 45 * Both [Bluesky PBC-operated](https://bsky.social) and self-hosted accounts supported 46 - * If you're using a `bsky.network` (`@*.bsky.social`) account, limit the amount of files you upload to Bluesky PBC's servers. Heed the copyright warning: **do not upload copyrighted files.** 46 + * If you're using a `bsky.network` (`@*.bsky.social`) account, limit the amount of files you upload to Bluesky PBC's servers. Heed the copyright warning: **do not upload copyrighted files** 47 47 * `did:web` accounts supported! 48 48 * Confirmed to work on [Bluesky PDS](https://github.com/bluesky-social/pds) and [millipds](https://github.com/DavidBuchanan314/millipds) 49 49 * Other PDSs remain untested, but if they implement standard `com.atproto.*` endpoints, there should be no reason these won't work ··· 64 64 65 65 This will automatically fetch the latest version of ATFile and install it in an appropriate location, as well as creating a blank configuration file. Once downloaded and installed, the locations used will be output. They are as follows: 66 66 67 - * **Linux/Windows/BSD/Solaris** 67 + * __Linux/Windows/*BSD/Solaris__ 68 68 * Install: `$HOME/.local/bin/atfile` 69 69 * As `sudo`/`root`: `/usr/local/bin/atfile` 70 70 * Config: `$HOME/.config/atfile.env` ··· 123 123 124 124 * **ยน** You can bypass OS detection in one of two ways: 125 125 * Set `ATFILE_SKIP_UNSUPPORTED_OS=1`<br />Be careful! There's a reason some OSes are not supported 126 - * Set `ATFILE_FORCE_OS=<os>`<br />This overrides the OS detected. Possible values: 127 - * BSD: `bsd-freebsd`, `bsd-netbsd`, `bsd-openbsd` 128 - * Linux: `linux`, `linux-mingw`, `linux-musl`, `linux-termux` 129 - * Other: `haiku`, `macos`, `solaris` 126 + * Set `ATFILE_FORCE_OS=<os>`<br />This overrides the OS detected. Possible values: `bsd`, `haiku`, `linux`, `linux-mingw`, `linux-musl`, `linux-termux`, `macos`, `solaris`, `unknown` 130 127 * **ยฒ** musl-powered distros do not use GNU/glibc packages, and have problems currently 131 128 * Known musl distros: Alpine, Chimera, Dragora, Gentoo (musl), Morpheus, OpenWrt, postmarketOS, Sabotage, Void 132 129 * Bypassing OS detection (see ยน) will work, but dates will not be handled correctly
+5
atfile.sh
··· 59 59 unset ATFILE_DEVEL_ENTRY 60 60 unset ATFILE_DEVEL_SOURCE 61 61 62 + #if [ -p /dev/stdin ] ||\ 63 + # [[ "$0" == "bash" || $0 == *"/bin/bash" ]]; then 64 + # atfile.devel.die "Piping is not supported" 65 + #fi 66 + 62 67 if [[ "${BASH_SOURCE[0]}" != "$0" ]]; then 63 68 ATFILE_DEVEL=1 64 69 ATFILE_DEVEL_DIR="$(dirname "${BASH_SOURCE[0]}")"
+56 -1
src/commands/install.sh
··· 1 1 #!/usr/bin/env bash 2 2 3 3 function atfile.install() { 4 - atfile.die "Not implemented" 4 + override_path="$1" 5 + override_version="$2" 6 + 7 + uid="$(id -u)" 8 + conf_file="atfile.env" 9 + install_file="atfile" 10 + unset conf_dir 11 + unset install_dir 12 + 13 + atfile.util.check_prog "curl" 14 + atfile.util.check_prog "jq" 15 + 16 + if [[ $_os_supported == 0 ]]; then 17 + atfile.die "Unsupported OS (${_os//unknown-/})" 18 + fi 19 + 20 + if [[ $_os == "haiku" ]]; then 21 + install_dir="/boot/system/non-packaged/bin" 22 + conf_dir="$HOME/config/settings" 23 + else 24 + if [[ $uid == 0 ]]; then 25 + install_dir="/usr/local/bin" 26 + 27 + if [[ -z $SUDO_DIR ]]; then 28 + conf_dir="/root/.config" 29 + else 30 + if [[ $_os == "macos" ]]; then 31 + conf_dir="$(eval echo ~"$SUDO_USER")/Library/Application Support" 32 + else 33 + conf_dir="$(eval echo ~"$SUDO_USER")/.config" 34 + fi 35 + fi 36 + else 37 + install_dir="$(eval echo ~"$USER")/.local/bin" 38 + conf_dir="$(eval echo ~"$USER")/.config" 39 + 40 + if [[ $_os == "macos" ]]; then 41 + conf_dir="$(eval echo ~"$USER")/Library/Application Support" 42 + else 43 + conf_dir="$(eval echo ~"$USER")/.config" 44 + fi 45 + fi 46 + 47 + # INVESTIGATE: What happens during `sudo`? 48 + if [[ -n "$XDG_CONFIG_HOME" ]]; then 49 + conf_dir="$XDG_CONFIG_HOME" 50 + fi 51 + fi 52 + 53 + [[ -n "$override_path" ]] && install_dir="$override_path" 54 + 55 + atfile.say.debug "Installing...\nโ†ณ OS: $_os\nโ†ณ Install: $install_dir/$install_file\nโ†ณ Config: $conf_dir/$conf_file" 56 + 57 + if [[ -f "$install_dir/$install_file" ]]; then 58 + atfile.die "Already installed ($install_dir/$install_file)" 59 + fi 5 60 }
+1 -1
src/commands/old_cmds.sh
··· 628 628 unset file_type 629 629 630 630 case "$_os" in 631 - "bsd-"*|"macos") 631 + "bsd"|"macos") 632 632 file_date="$(atfile.util.get_date "$(stat -f '%Sm' -t "%Y-%m-%dT%H:%M:%SZ" "$file")")" 633 633 file_size="$(stat -f '%z' "$file")" 634 634 file_type="$(file -b --mime-type "$file")"
+7 -2
src/commands/update.sh
··· 4 4 function atfile.update() { 5 5 cmd="$1" 6 6 unset error 7 + is_git=0 8 + 9 + if [ -x "$(command -v git)" ] && [[ -d "$_prog_dir/.git" ]] && [[ "$(atfile.util.get_realpath "$(pwd)")" == "$_prog_dir" ]]; then 10 + is_git=1 11 + fi 7 12 8 13 if [[ "$cmd" == "check-only" ]]; then 9 14 # shellcheck disable=SC2154 ··· 11 16 # shellcheck disable=SC2154 12 17 [[ $_disable_updater == 1 ]] && return 13 18 # shellcheck disable=SC2154 14 - [[ $_is_git == 1 && $_enable_update_git_clobber == 0 ]] && return 19 + [[ $is_git == 1 && $_enable_update_git_clobber == 0 ]] && return 15 20 # shellcheck disable=SC2154 16 21 [[ $_output_json == 1 ]] && return 17 22 ··· 78 83 return 79 84 fi 80 85 81 - [[ $_is_git == 1 && $_enable_update_git_clobber == 0 ]] &&\ 86 + [[ $is_git == 1 && $_enable_update_git_clobber == 0 ]] &&\ 82 87 atfile.die "Cannot update in Git repository" 83 88 [[ $_disable_updater == 1 ]] &&\ 84 89 atfile.die "Cannot update system-managed version: update from your package manager"
+69 -40
src/entry.sh
··· 1 1 #!/usr/bin/env bash 2 2 3 - # Global variables 3 + # Environment 4 4 5 - ## General 5 + ## Early-start global variables 6 6 7 - _start="$(atfile.util.get_date "" "%s")" 7 + _start="$(atfile.util.get_date "" "%s")" # 1 8 + _envvar_prefix="ATFILE" # 2 9 + _debug="$(atfile.util.get_envvar "${_envvar_prefix}_DEBUG" "0")" # 3 8 10 _command="$1" 9 11 _command_args=("${@:2}") 10 - _envvar_prefix="ATFILE" 11 12 _os="$(atfile.util.get_os)" 12 - _is_git=0 13 + _os_supported=0 14 + _is_piped=0 13 15 _is_sourced=0 14 16 _meta_author="{:meta_author:}" 15 17 _meta_did="{:meta_did:}" ··· 17 19 _meta_year="{:meta_year:}" 18 20 _now="$(atfile.util.get_date)" 19 21 _version="{:version:}" 22 + 23 + ## "Hello, world!" 24 + 25 + atfile.say.debug "Reticulating splines..." 26 + 27 + ## OS detection 28 + 29 + atfile.say.debug "Detected OS: $_os" 30 + 31 + if [[ $_os != "unknown-"* ]] &&\ 32 + [[ $_os == "bsd" ]] ||\ 33 + [[ $_os == "haiku" ]] ||\ 34 + [[ $_os == "linux" ]] ||\ 35 + [[ $_os == "linux-mingw" ]] ||\ 36 + [[ $_os == "linux-termux" ]] ||\ 37 + [[ $_os == "macos" ]] ; then 38 + _os_supported=1 39 + fi 40 + 41 + ## Pipe detection 42 + 43 + if [ -p /dev/stdin ] ||\ 44 + [[ "$0" == "bash" || $0 == *"/bin/bash" ]]; then 45 + _is_piped=1 46 + atfile.say.debug "Piping: $0" 47 + fi 48 + 49 + ## Source detection 50 + 51 + if [[ -n ${BASH_SOURCE[0]} ]]; then 52 + if [[ "$0" != "${BASH_SOURCE[0]}" ]]; then 53 + if [[ "$ATFILE_DEVEL" == 1 ]]; then 54 + if [[ -n "$ATFILE_DEVEL_SOURCE" ]]; then 55 + _is_sourced=1 56 + atfile.say.debug "Sourcing: $ATFILE_DEVEL_SOURCE" 57 + fi 58 + else 59 + _is_sourced=1 60 + atfile.say.debug "Sourcing: ${BASH_SOURCE[0]}" 61 + fi 62 + fi 63 + fi 64 + 65 + # Installation 66 + 67 + if [[ $_is_piped == 1 ]] ||\ 68 + [[ "$1" == "install" ]]; then 69 + if [[ "$1" == "install" ]]; then 70 + atfile.install "$2" "$3" 71 + install_exit="$?" 72 + else 73 + atfile.install "$1" "$2" 74 + install_exit="$?" 75 + fi 76 + 77 + atfile.util.print_seconds_since_start_debug 78 + exit $install_exit 79 + fi 80 + 81 + # Global variables 20 82 21 83 ## Reflection 22 84 ··· 150 212 151 213 # Setup 152 214 153 - atfile.say.debug "Starting up..." 154 - 155 - ## Source detection 156 - 157 - if [[ "$0" != "${BASH_SOURCE[0]}" ]]; then 158 - if [[ "$ATFILE_DEVEL" == 1 ]]; then 159 - if [[ -n "$ATFILE_DEVEL_SOURCE" ]]; then 160 - _is_sourced=1 161 - atfile.say.debug "Sourcing: $ATFILE_DEVEL_SOURCE" 162 - fi 163 - else 164 - _is_sourced=1 165 - atfile.say.debug "Sourcing: ${BASH_SOURCE[0]}" 166 - fi 167 - fi 168 - 169 215 ## Envvar correction 170 216 171 217 ### Overrides ··· 202 248 atfile.say.debug "Setting ${_envvar_prefix}_MAX_LIST to $_max_list_fallback\nโ†ณ Maximum is $_max_list_fallback" &&\ 203 249 _max_list=$_max_list_fallback 204 250 205 - ## Git detection 206 - 207 - if [ -x "$(command -v git)" ] && [[ -d "$_prog_dir/.git" ]] && [[ "$(atfile.util.get_realpath "$(pwd)")" == "$_prog_dir" ]]; then 208 - _is_git=1 209 - fi 210 - 211 251 ## OS detection 212 252 213 - atfile.say.debug "Checking OS is supported...\nโ†ณ Detected: $_os" 214 - is_os_supported=0 215 - 216 - if [[ $_os != "unknown-"* ]] &&\ 217 - [[ $_os == "bsd-"* ]] ||\ 218 - [[ $_os == "haiku" ]] ||\ 219 - [[ $_os == "linux" ]] ||\ 220 - [[ $_os == "linux-mingw" ]] ||\ 221 - [[ $_os == "linux-termux" ]] ||\ 222 - [[ $_os == "macos" ]] ; then 223 - is_os_supported=1 224 - fi 253 + atfile.say.debug "Checking OS is supported..." 225 254 226 - if [[ $is_os_supported == 0 ]]; then 255 + if [[ $_os_supported == 0 ]]; then 227 256 if [[ $_skip_unsupported_os_warn == 0 ]]; then 228 257 atfile.die "Unsupported OS (${_os//unknown-/})\nโ†ณ Set ${_envvar_prefix}_SKIP_UNSUPPORTED_OS_WARN=1 to ignore" 229 258 else
+1 -1
src/shared/die.sh
··· 3 3 function atfile.die() { 4 4 message="$1" 5 5 6 - if [[ $_output_json == 0 ]]; then 6 + if [[ $_output_json != 1 ]]; then 7 7 atfile.say.die "$message" 8 8 else 9 9 echo -e "{ \"error\": \"$1\" }" | jq
+11 -11
src/shared/util.sh
··· 208 208 [[ -z $format ]] && format="%Y-%m-%dT%H:%M:%SZ" 209 209 210 210 if [[ $date =~ ^([0-9]{4}-[0-9]{2}-[0-9]{2})T([0-9]{2}:[0-9]{2}:[0-9]{2}([.][0-9]{3}){0,1})Z$ ]]; then 211 - if [[ $_os == "bsd-"* ]]; then 211 + if [[ $_os == "bsd" ]]; then 212 212 date="${BASH_REMATCH[1]} ${BASH_REMATCH[2]}" 213 213 in_format="%Y-%m-%d %H:%M:%S" 214 214 elif [[ $_os == "linux-musl" || $_os == "solaris" ]]; then ··· 227 227 else 228 228 if [[ $_os == "linux-musl" || $_os == "solaris" ]]; then 229 229 date -u -d "$date" 230 - elif [[ $_os == "bsd-"* || $_os == "macos" ]]; then 230 + elif [[ $_os == "bsd" || $_os == "macos" ]]; then 231 231 date -u -j -f "$in_format" "$date" +"$format" 232 232 else 233 233 date --date "$date" -u +"$format" ··· 306 306 307 307 function atfile.util.get_envvar_from_envfile() { 308 308 variable="$1" 309 - atfile.util.get_var_from_file "$_path_envvar" "$variable" 309 + [[ -f $_path_envvar ]] && atfile.util.get_var_from_file "$_path_envvar" "$variable" 310 310 } 311 311 312 312 function atfile.util.get_exiftool_field() { ··· 646 646 } 647 647 648 648 function atfile.util.get_os() { 649 - os="$OSTYPE" 649 + os="${OSTYPE,,}" 650 650 651 651 case $os in 652 + # BSD 653 + "freebsd"*|"netbsd"*|"openbsd"*|*"bsd") echo "bsd" ;; 654 + # Haiku 655 + "haiku") echo "haiku" ;; 652 656 # Linux 653 657 "linux-gnu") echo "linux" ;; 654 658 "cygwin"|"msys") echo "linux-mingw" ;; 655 659 "linux-musl") echo "linux-musl" ;; 656 660 "linux-android") echo "linux-termux" ;; 657 - # BSD 658 - "FreeBSD"*|"freebsd"*) echo "bsd-freebsd" ;; 659 - "netbsd"*) echo "bsd-netbsd" ;; 660 - "openbsd"*) echo "bsd-openbsd" ;; 661 - # Misc. 662 - "haiku") echo "haiku" ;; 661 + # macOS 663 662 "darwin"*) echo "macos" ;; 663 + # Solaris 664 664 "solaris"*) echo "solaris" ;; 665 665 # Unknown 666 - *) echo "unknown-$OSTYPE" ;; 666 + *) echo "unknown-$os" ;; 667 667 esac 668 668 } 669 669