Outils pour utilisateurs

Outils du site


script_de_mise_a_jour_misskey

Script de mise à jour pour Misskey

Petit script qui automatise la mise à jour d'une instance Misskey.

    #!/bin/bash
## author      : Dryusdan
## modified    : KazukyAkayashi
## date        : 16/04/2020
## description : Misskey Update
 
## Bash strict mode ####################################
set -o errexit   # abort on nonzero exitstatus
set -o nounset   # abort on unbound variable
set -o pipefail  # don't hide errors within pipes
 
## Bash color ##########################################
# Set colors
RED='\033[0;31m'
YELLOW='\033[00;33m'
LRED='\033[01;31m'
LBLUE='\033[01;34m'
NC='\033[0m' # No Color
 
## Logs ################################################
readonly SCRIPTNAME="$(basename "$0")"
info()    { echo -e "${LBLUE}[INFO] $* ${NC}"    | logger --tag "${SCRIPTNAME}" --stderr ; }
warning() { echo -e "${YELLOW}[WARNING] $* ${NC}" | logger --tag "${SCRIPTNAME}" --stderr ; }
error()   { echo -e "${LRED}[ERROR] $* ${NC}"   | logger --tag "${SCRIPTNAME}" --stderr ; }
fatal()   { echo -e "${RED}[FATAL] $* ${NC}"   | logger --tag "${SCRIPTNAME}" --stderr ; exit 1 ; }
########################################################
 
## Define Misskey's config ##########################
FOLDER="/your/path/"
MISSKEYSERVICE="misskey.service"
MISSKEYUSER="misskey"
 
info "Stopping Misskey"
systemctl stop ${MISSKEYSERVICE}
 
# Go to ${FOLDER}
info "Go to Misskey folder"
cd ${FOLDER}
 
# Download
info "Download"
## Uncomment if you have trouble with git
# su - ${MISSKEYUSER} -s /bin/bash -c "git reset --hard"
su - ${MISSKEYUSER} -s /bin/bash -c "git checkout master"
su - ${MISSKEYUSER} -s /bin/bash -c "git pull"
su - ${MISSKEYUSER} -s /bin/bash -c "git submodule update --init"
 
# Build
info "Install and update dependencies"
su - ${MISSKEYUSER} -s /bin/bash -c "NODE_OPTIONS=--max_old_space_size=3072 NODE_ENV=production pnpm install --frozen-lockfile;"
 
info "Build assets"
su - ${MISSKEYUSER} -s /bin/bash -c "NODE_OPTIONS=--max_old_space_size=3072 NODE_ENV=production pnpm build;"
 
info "Migrate"
su - ${MISSKEYUSER} -s /bin/bash -c "NODE_OPTIONS=--max_old_space_size=3072 NODE_ENV=production pnpm run migrate;"
 
info "Starting Misskey"
systemctl start ${MISSKEYSERVICE}
 
## END Script #####################################
info "exiting ${SCRIPTNAME}"
exit 0
script_de_mise_a_jour_misskey.txt · Dernière modification: 2023/02/12 09:03 de kazukyakayashi