9c67b209b95ccff744455e92055e7a7974735304
2 # XXX: This should be removed when elixir's releases get custom command support
6 if [ "$arch" = "x86_64" ]; then
8 elif [ "$arch" = "armv7l" ]; then
10 elif [ "$arch" = "aarch64" ]; then
13 echo "Unsupported arch: $arch" >&2
17 if getconf GNU_LIBC_VERSION
>/dev
/null
; then
19 elif [ "$(ldd 2>&1 | head -c 9)" = "musl libc" ]; then
21 elif [ "$(find /lib/libc.musl* | wc -l)" ]; then
24 echo "Unsupported libc" >&2
28 echo "$arch$libc_postfix"
32 version
="$(cut -d' ' -f2 <"$RELEASE_ROOT"/releases/start_erl.data)"
33 branch
="$(echo "$version" | cut -d'-' -f 4)"
34 if [ "$branch" = "develop" ]; then
36 elif [ "$branch" = "" ]; then
39 echo "Releases are built only for master and develop branches" >&2
45 RELEASE_ROOT
=$(dirname "$SCRIPTPATH")
46 uri
="${PLEROMA_CTL_URI:-https://git.pleroma.social}"
47 project_id
="${PLEROMA_CTL_PROJECT_ID:-2}"
48 project_branch
="$(detect_branch)"
49 flavour
="${PLEROMA_CTL_FLAVOUR:-$(detect_flavour)}"
50 echo "Detected flavour: $flavour"
51 tmp
="${PLEROMA_CTL_TMP_DIR:-/tmp}"
52 artifact
="$tmp/pleroma.zip"
53 full_uri
="${uri}/api/v4/projects/${project_id}/jobs/artifacts/${project_branch}/download?job=${flavour}"
54 echo "Downloading the artifact from ${full_uri} to ${artifact}"
55 curl
"$full_uri" -o "${artifact}"
56 echo "Unpacking ${artifact} to ${tmp}"
57 unzip -q "$artifact" -d "$tmp"
58 echo "Copying files over to $RELEASE_ROOT"
59 if [ "$1" != "--no-rm" ]; then
60 rm -r "${RELEASE_ROOT:-?}"/*
62 cp -rf "$tmp/release"/* "$RELEASE_ROOT"
63 echo "Removing temporary files"
66 echo "Done! Please refer to the changelog/release notes for changes and update instructions"
70 if [ -z "$1" ] || [ "$1" = "help" ]; then
71 # TODO: Just list the commands on `pleroma_ctl help` and output help for the individual command on `pleroma_ctl help $COMMAND`
72 echo "Usage: $(basename "$0") COMMAND [ARGS]
74 The known commands are:
77 Create database schema (needs to be executed only once)
80 Execute database migrations (needs to be done after updates)
83 Rollback database migrations (needs to be done before downgrading)
86 Update the instance using the latest CI artifact for the current branch.
88 The only supported option is --no-rm, when set the script won't delete the whole directory, but
89 just force copy over files from the new release. This wastes more space, but may be useful if
90 some files are stored inside of the release directories (although you really shouldn't store them
91 there), or if you want to be able to quickly revert a broken update.
93 The script will try to detect your architecture and ABI and set a flavour automatically,
94 but if it is wrong, you can overwrite it by setting PLEROMA_CTL_FLAVOUR to the desired flavour.
96 By default the artifact will be downloaded from https://git.pleroma.social for pleroma/pleroma (project id: 2)
97 to /tmp/, you can overwrite these settings by setting PLEROMA_CTL_URI, PLEROMA_CTL_PROJECT_ID and PLEROMA_CTL_TMP_DIR
101 and any mix tasks under Pleroma namespace, for example \`mix pleroma.user COMMAND\` is
102 equivalent to \`$(basename "$0") user COMMAND\`
104 By default pleroma_ctl will try calling into a running instance to execute non migration-related commands,
105 if for some reason this is undesired, set PLEROMA_CTL_RPC_DISABLED environment variable
108 SCRIPT
=$(readlink -f "$0")
109 SCRIPTPATH
=$(dirname "$SCRIPT")
111 if [ "$1" = "update" ]; then
113 elif [ "$1" = "migrate" ] || [ "$1" = "rollback" ] || [ "$1" = "create" ] || [ "$1 $2" = "instance gen" ] || [ -n "$PLEROMA_CTL_RPC_DISABLED" ]; then
114 "$SCRIPTPATH"/pleroma
eval 'Pleroma.ReleaseTasks.run("'"$*"'")'
116 "$SCRIPTPATH"/pleroma rpc
'Pleroma.ReleaseTasks.run("'"$*"'")'