diff options
author | Fabian Bornschein | 2022-04-21 15:55:20 +0200 |
---|---|---|
committer | Fabian Bornschein | 2022-04-21 15:55:20 +0200 |
commit | 14e8965d74aca046ec815d6a3b7e731b1da526ba (patch) | |
tree | 52e23d43f95dcfb15a182adff1e33c3ada6f105c | |
parent | 252bd63d47f9a0e78ff37cf6c975ad4c98c22404 (diff) | |
download | aur-14e8965d74aca046ec815d6a3b7e731b1da526ba.tar.gz |
extract db-upgrade functionality into an own script in cases the user needs to run it manually + small cleanup
-rw-r--r-- | .SRCINFO | 9 | ||||
-rw-r--r-- | PKGBUILD | 42 | ||||
-rwxr-xr-x | misskey-db-upgrade.sh | 32 | ||||
-rw-r--r-- | misskey.install | 35 |
4 files changed, 66 insertions, 52 deletions
@@ -1,7 +1,7 @@ pkgbase = misskey pkgdesc = 🌎 An interplanetary microblogging platform 🚀 (Experimental) pkgver = 12.110.0 - pkgrel = 2 + pkgrel = 3 url = https://github.com/misskey-dev/misskey install = misskey.install arch = x86_64 @@ -20,16 +20,19 @@ pkgbase = misskey source = git+https://github.com/misskey-dev/misskey.git#commit=33c22b5f3efa4110c9b517c224c9fdfba7e6c64b source = misskey.install source = misskey.service + source = misskey-db-upgrade.sh source = misskey.sysusers source = misskey.tmpfiles md5sums = SKIP - md5sums = aa0312f32fe331cd7a2e471902dad1f4 + md5sums = 74797428d78ba89b328c7ef98fda2786 md5sums = 9abc87cea2314b95334d4ad3b309e931 + md5sums = 482ab8e6ce416e4490459b4dd78cc158 md5sums = a3fe48c606eabebf818106648c0bf0d9 md5sums = c6f7dc5885f8db2329b3b1e3c2a67ef5 sha256sums = SKIP - sha256sums = d860082dbc90b0e7ecadcb1bfeeeb11dae6f24544d4746883e4a2bfafd052284 + sha256sums = 60cd6fb87a1ecde4db123cfa70ea308fb4559c3a0f5f84920af8473dcc9522a1 sha256sums = 5cd19f1798eb1852c47c7786021adede99d95ab83feb0802e7b1fba50a308517 + sha256sums = 88d8c9853aa2ac070ff76c59d7ae4d61bbd5ae50b141794f50d91bc350954974 sha256sums = a3ff9c1b77920ebbb0df8fb1affe9e8ef54d907bd4d16ed7c6076cbf52726df7 sha256sums = c368b2ed2efbeca0e488f883defb2ccb7ed4661cc6832d2c396176206a794f34 @@ -2,7 +2,7 @@ pkgname=misskey pkgver=12.110.0 -pkgrel=2 +pkgrel=3 pkgdesc="🌎 An interplanetary microblogging platform 🚀 (Experimental)" url="https://github.com/misskey-dev/misskey" arch=("x86_64") @@ -17,16 +17,19 @@ _commit="33c22b5f3efa4110c9b517c224c9fdfba7e6c64b" #tag/12.110.0 source=("git+https://github.com/misskey-dev/misskey.git#commit=${_commit}" "${pkgname}.install" "${pkgname}.service" + "${pkgname}-db-upgrade.sh" "${pkgname}.sysusers" "${pkgname}.tmpfiles") md5sums=('SKIP' - 'aa0312f32fe331cd7a2e471902dad1f4' + '74797428d78ba89b328c7ef98fda2786' '9abc87cea2314b95334d4ad3b309e931' + '482ab8e6ce416e4490459b4dd78cc158' 'a3fe48c606eabebf818106648c0bf0d9' 'c6f7dc5885f8db2329b3b1e3c2a67ef5') sha256sums=('SKIP' - 'd860082dbc90b0e7ecadcb1bfeeeb11dae6f24544d4746883e4a2bfafd052284' + '60cd6fb87a1ecde4db123cfa70ea308fb4559c3a0f5f84920af8473dcc9522a1' '5cd19f1798eb1852c47c7786021adede99d95ab83feb0802e7b1fba50a308517' + '88d8c9853aa2ac070ff76c59d7ae4d61bbd5ae50b141794f50d91bc350954974' 'a3ff9c1b77920ebbb0df8fb1affe9e8ef54d907bd4d16ed7c6076cbf52726df7' 'c368b2ed2efbeca0e488f883defb2ccb7ed4661cc6832d2c396176206a794f34') @@ -37,16 +40,16 @@ pkgver() { prepare() { cd "${pkgname}" - + # Dependency handling git submodule update --init HOME="${srcdir}/${pkgname}" yarn install - + # Example configuration ## Change example configuration to reflect ## this packages purpose _example_file="${srcdir}/${pkgname}/.config/example.yml" - + sed -i \ 's|example-misskey-user|misskey|; s| pass: example-misskey-pass|# pass: misskey|; @@ -57,7 +60,7 @@ prepare() { build() { cd "${pkgname}" NODE_ENV=production HOME="${srcdir}/${pkgname}" yarn build - + # Cleanup find "${srcdir}/${pkgname}" \ -depth \ @@ -68,7 +71,8 @@ build() { -o -iname 'darwin-arm64' \ -o -iname 'darwin-x64' \ -o -iname 'win32-ia32' \ - -o -iname 'win32-x64' \) \ + -o -iname 'win32-x64' \ + -o -iname 'linux-arm64' \) \ -execdir rm -rf '{}' \; find "${srcdir}/${pkgname}" \ -type f \ @@ -96,29 +100,33 @@ build() { package() { # systemd files install -Dm644 ${pkgname}.service -t "${pkgdir}"/usr/lib/systemd/system/ - install -Dm644 ${pkgname}.sysusers "${pkgdir}"/usr/lib/sysusers.d/${pkgname}.conf - install -Dm644 ${pkgname}.tmpfiles "${pkgdir}"/usr/lib/tmpfiles.d/${pkgname}.conf - + install -Dm644 ${pkgname}.sysusers "${pkgdir}/usr/lib/sysusers.d/${pkgname}.conf" + install -Dm644 ${pkgname}.tmpfiles "${pkgdir}/usr/lib/tmpfiles.d/${pkgname}.conf" + install -dm755 "${pkgdir}/usr/share/webapps" mv "${srcdir}/${pkgname}" "${pkgdir}/usr/share/webapps/" - + # config setup install -dm755 "${pkgdir}/etc/webapps/${pkgname}" mv "${pkgdir}/usr/share/webapps/${pkgname}/.config/example.yml" -t \ "${pkgdir}/etc/webapps/${pkgname}/" rmdir "${pkgdir}/usr/share/webapps/${pkgname}/.config" ln -s "/etc/webapps/${pkgname}" "${pkgdir}/usr/share/webapps/${pkgname}/.config" - + # cache setup ln -s "/var/cache/${pkgname}" "${pkgdir}/usr/share/webapps/${pkgname}/.cache" - + # yarn, npm setup ln -s "/var/lib/${pkgname}/yarn" "${pkgdir}/usr/share/webapps/${pkgname}/.yarn" ln -s "/var/lib/${pkgname}/npm" "${pkgdir}/usr/share/webapps/${pkgname}/.npm" - + # files (upload, …) - ln -s "/var/lib/${pkgname}/files" "${pkgdir}/usr/share/webapps/${pkgname}/files" - + ln -s "/var/lib/${pkgname}/files" "${pkgdir}/usr/share/webapps/${pkgname}/files" + + # db-update script + install -dm755 "${pkgdir}/usr/lib/${pkgname}" + install -Dm700 "${pkgname}-db-upgrade.sh" -t "${pkgdir}/usr/lib/${pkgname}" + # license install -Dm644 "${pkgdir}/usr/share/webapps/${pkgname}/COPYING" \ "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE" diff --git a/misskey-db-upgrade.sh b/misskey-db-upgrade.sh new file mode 100755 index 000000000000..c95fae3f7762 --- /dev/null +++ b/misskey-db-upgrade.sh @@ -0,0 +1,32 @@ +#! /usr/bin/env sh + +if [ $(id -u) -ne 0 ]; then + printf "You need to be root\n" + exit 1 +fi + +## Migration needs PostgreSQL + redis running. +## Don't migrate if not running +if /usr/bin/systemctl is-active postgresql.service > /dev/null \ + && /usr/bin/systemctl is-active redis.service > /dev/null; then + ## misskey needs to be stopped, check for this + if /usr/bin/systemctl is-active misskey.service; then + printf "Shutting down misskey\n" + MK_ACTIVE=1 + /usr/bin/systemctl stop misskey.service + fi + printf "Migrate data to new version\n" + cd "/usr/share/webapps/misskey/" + /usr/bin/runuser -u misskey -- env HOME="/usr/share/webapps/misskey" yarn migrate + if ! [ -z ${MK_ACTIVE+x} ] ; then + printf "starting up misskey\n" + /usr/bin/systemctl start misskey.service + else + printf "Misskey service is *not* started\n" + printf "Thats your job!\n" + fi +else + printf "Misskey migration was not started because PostgreSQL and or redis is inactive.\n" + printf "Please start the services and run\n" + printf "# /usr/lib/misskey/misskey-db-upgrade.sh\n" +fi diff --git a/misskey.install b/misskey.install index d7b7e74bf28c..9c56097158ad 100644 --- a/misskey.install +++ b/misskey.install @@ -2,20 +2,8 @@ post_install() { printf "You've successfully installed misskey!\n" if ! [ -f "/etc/webapps/misskey/default.yml" ]; then cp "/etc/webapps/misskey/example.yml" "/etc/webapps/misskey/default.yml" - printf "There is a list of things you need to do now.\n" - printf "1. Edit the default.yml to reflect your systems configuration\n" - printf "2. Setup PostgreSQL\n" - printf "3. Add a PostgreSQL user \"misskey\" and a database for this user also called \"misskey\"\n" - printf "4. Startup redis.service\n" - printf "^^^^^^^^ Only after thats done ^^^^^^^^\n" - printf "5. Run the database initialisation as root user\n" - printf " cd \"/usr/share/webapps/misskey/\"\n" - printf " runuser -u misskey -- env HOME=\"/usr/share/webapps/misskey\" yarn run init\n" - printf "6. Finally start misskey.service\n" - printf "More on the setup: https://misskey-hub.net/en/docs/install/manual.html\n" - printf "#TODO: Yes, this needs to be in the wiki." - fi - printf "You need to configure a reverse-proxy to grand network access localhost:3000\n" + fi + printf "More on the setup: https://wiki.archlinux.org/title/Misskey\n" } ## $1: new package version @@ -34,23 +22,6 @@ pre_upgrade() { post_upgrade() { ## Ignore reinstallations of the same or older versions if [ $(vercmp $1 $2) -gt 0 ] ; then - ## Dont do anything if there is no default configuration (not setup) - if [ -f "/etc/webapps/misskey/default.yml" ]; then - ## Migration needs PostgreSQL + redis running. Dont migrate if not running - if systemctl is-active postgresql.service > /dev/null \ - && systemctl is-active redis.service > /dev/null; then - printf "Migrate data to new version\n" - cd "/usr/share/webapps/misskey/" - runuser -u misskey -- env HOME=/usr/share/webapps/misskey yarn migrate - printf "Misskey service is *not* started\n" - printf "Thats your job!\n" - else - printf "Misskey migration was not started because PostgreSQL and or redis is inactive." - printf "Please start the services and run\n" - printf " cd /usr/share/webapps/misskey\n" - printf " HOME=/usr/share/webapps/misskey yarn migrate\n" - printf "as misskey user manually\n" - fi - fi + /usr/lib/misskey/misskey-db-upgrade.sh fi } |