2 # XXX: This should be removed when elixir's releases get custom command support
6 if [ "$arch" = "x86_64" ]; then
8 elif [ "$arch" = "aarch64" ]; then
11 echo "Unsupported arch: $arch" >&2
15 if getconf GNU_LIBC_VERSION
>/dev
/null
; then
17 elif [ "$(ldd 2>&1 | head -c 9)" = "musl libc" ]; then
19 elif [ "$(find /lib/libc.musl* | wc -l)" ]; then
22 echo "Unsupported libc" >&2
26 echo "$arch$libc_postfix"
30 version
="$(cut -d' ' -f2 <"$RELEASE_ROOT"/releases/start_erl.data)"
31 # Expected format: major.minor.patch_version(-number_of_commits_ahead_of_tag-gcommit_hash).branch
32 branch
="$(echo "$version" | cut -d'.' -f 4)"
33 if [ "$branch" = "develop" ]; then
35 elif [ "$branch" = "" ]; then
38 # Note: branch name in version is of SemVer format and may only contain [0-9a-zA-Z-] symbols —
39 # if supporting releases for more branches, need to ensure they contain only these symbols.
40 echo "Can't detect the branch automatically, please specify it by using the --branch option." >&2
48 while echo "$1" | grep "^-" >/dev
/null
; do
71 echo "invalid option: $1" 1>&2
77 RELEASE_ROOT
=$(dirname "$SCRIPTPATH")
78 uri
="https://akkoma-updates.s3-website.fr-par.scw.cloud"
80 project_branch
="${BRANCH:-$(detect_branch)}"
81 flavour
="${FLAVOUR:-$(detect_flavour)}"
82 tmp
="${TMP_DIR:-/tmp}"
83 artifact
="$tmp/pleroma.zip"
84 full_uri
="${FULL_URI:-${uri}/${project_branch}/akkoma-${flavour}}.zip"
85 echo "Downloading the artifact from ${full_uri} to ${artifact}"
86 curl
"$full_uri" -o "${artifact}"
87 echo "Unpacking ${artifact} to ${tmp}"
88 unzip -q "$artifact" -d "$tmp"
89 echo "Copying files over to $RELEASE_ROOT"
90 if [ "$NO_RM" = false
]; then
91 echo "Removing files from the previous release"
92 rm -r "${RELEASE_ROOT:-?}"/*
94 cp -rf "$tmp/release"/* "$RELEASE_ROOT"
95 echo "Removing temporary files"
98 echo "Done! Please refer to the changelog/release notes for changes and update instructions"
102 if [ -z "$1" ] || [ "$1" = "help" ]; then
103 # TODO: Just list the commands on `pleroma_ctl help` and output help for the individual command on `pleroma_ctl help $COMMAND`
104 echo "Usage: $(basename "$0") COMMAND [ARGS]
106 The known commands are:
109 Create database schema (needs to be executed only once)
112 Execute database migrations (needs to be done after updates)
115 Rollback database migrations (needs to be done before downgrading)
121 --branch Update to a specified branch, instead of the latest version of the current one.
122 --flavour Update to a specified flavour (CPU architecture+libc), instead of the current one.
123 --zip-url Get the release from a specified url. If set, renders the previous 2 options inactive.
124 --no-rm Do not erase previous release's files.
125 --tmp-dir Download the temporary files to a specified directory.
127 and any mix tasks under Pleroma namespace, for example \`mix pleroma.user COMMAND\` is
128 equivalent to \`$(basename "$0") user COMMAND\`
130 By default pleroma_ctl will try calling into a running instance to execute non migration-related commands,
131 if for some reason this is undesired, set PLEROMA_CTL_RPC_DISABLED environment variable.
135 SCRIPT
=$(readlink -f "$0")
136 SCRIPTPATH
=$(dirname "$SCRIPT")
141 if [ $# -gt 0 ]; then
144 echo "$1" | grep "^-" >/dev
/null
145 if [ $?
-eq 1 ]; then
147 if [ $# -gt 0 ]; then
152 if [ "$ACTION" = "update" ]; then
154 elif [ "$ACTION" = "migrate" ] || [ "$ACTION" = "rollback" ] || [ "$ACTION" = "create" ] || [ "$ACTION $SUBACTION" = "instance gen" ] || [ "$PLEROMA_CTL_RPC_DISABLED" = true
]; then
155 "$SCRIPTPATH"/pleroma
eval 'Pleroma.ReleaseTasks.run("'"$FULL_ARGS"'")'
157 "$SCRIPTPATH"/pleroma rpc
'Pleroma.ReleaseTasks.run("'"$FULL_ARGS"'")'