Skip to content
GitLab
Explorer
Connexion
Navigation principale
Rechercher ou aller à…
Projet
matrix-stickers
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Wiki
Wiki externe
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Extraits de code
Compilation
Pipelines
Jobs
Planifications de pipeline
Artéfacts
Déploiement
Releases
Registre de paquets
Registre de conteneur
Registre de modèles
Opération
Environnements
Modules Terraform
Surveillance
Incidents
Analyse
Données d'analyse des chaînes de valeur
Analyse des contributeurs
Données d'analyse CI/CD
Données d'analyse du dépôt
Expériences du modèle
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté
Contribuer à GitLab
Donner votre avis
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
Elliu
matrix-stickers
Validations
ded612a7
Valider
ded612a7
rédigé
Il y a 6 mois
par
salixor
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
Add a migration script
parent
6f3d2be4
Aucune branche associée trouvée
Branches contenant la validation
Aucune étiquette associée trouvée
1 requête de fusion
!6
Add a migration script
Modifications
1
Masquer les modifications d'espaces
En ligne
Côte à côte
Affichage de
1 fichier modifié
stpkg
+62
-2
62 ajouts, 2 suppressions
stpkg
avec
62 ajouts
et
2 suppressions
stpkg
+
62
−
2
Voir le fichier @
ded612a7
...
@@ -34,6 +34,7 @@ if [ "x$STPKG_COLORS" = "x" ]; then
...
@@ -34,6 +34,7 @@ if [ "x$STPKG_COLORS" = "x" ]; then
__red
()
{
echo
-ne
'\e[31m'
$*
'\e[0m'
;
}
__red
()
{
echo
-ne
'\e[31m'
$*
'\e[0m'
;
}
__green
()
{
echo
-ne
'\e[32m'
$*
'\e[0m'
;
}
__green
()
{
echo
-ne
'\e[32m'
$*
'\e[0m'
;
}
__yellow
()
{
echo
-ne
'\e[33m'
$*
'\e[0m'
;
}
__yellow
()
{
echo
-ne
'\e[33m'
$*
'\e[0m'
;
}
__magenta
()
{
echo
-ne
'\e[35m'
$*
'\e[0m'
;
}
__bold
()
{
echo
-ne
'\033[1m'
$*
'\e[0m'
;
}
__bold
()
{
echo
-ne
'\033[1m'
$*
'\e[0m'
;
}
__italic
()
{
echo
-ne
'\033[3m'
$*
'\e[0m'
;
}
__italic
()
{
echo
-ne
'\033[3m'
$*
'\e[0m'
;
}
...
@@ -110,6 +111,7 @@ cat << EOF
...
@@ -110,6 +111,7 @@ cat << EOF
$BASE_NAME
pack [`__yellow "-t token"`] [`__yellow "name"`] <`__yellow "pack_folder"`>
$BASE_NAME
pack [`__yellow "-t token"`] [`__yellow "name"`] <`__yellow "pack_folder"`>
$BASE_NAME
edit [`__yellow "-t token"`] <`__yellow "pack_name"`> add|del <`__yellow "sticker"`> [`__yellow "file"`]
$BASE_NAME
edit [`__yellow "-t token"`] <`__yellow "pack_name"`> add|del <`__yellow "sticker"`> [`__yellow "file"`]
$BASE_NAME
display [`__yellow "-dl folder"`] <`__yellow "pack_name"`> [`__yellow "sticker_regex"`]
$BASE_NAME
display [`__yellow "-dl folder"`] <`__yellow "pack_name"`> [`__yellow "sticker_regex"`]
$BASE_NAME
migrate <`__yellow "pack_name"`>
`__bold Flags:`
`__bold Flags:`
`__yellow "-e"` / `__yellow "-ne"` The pack is enabled / disabled
`__yellow "-e"` / `__yellow "-ne"` The pack is enabled / disabled
...
@@ -857,7 +859,11 @@ __pack() {
...
@@ -857,7 +859,11 @@ __pack() {
ST_JSON
=
"
`
jq
--arg
STICKER_NAME
"
$STICKER_NAME
"
'.stickers[] | select(.body == $STICKER_NAME)'
<
"
$DEST_INDEX
"
`
"
ST_JSON
=
"
`
jq
--arg
STICKER_NAME
"
$STICKER_NAME
"
'.stickers[] | select(.body == $STICKER_NAME)'
<
"
$DEST_INDEX
"
`
"
else
else
if
[[
"x
${
updatedFiles
[
$FILE
]
}
"
!=
"x"
]]
;
then
if
[[
"x
${
updatedFiles
[
$FILE
]
}
"
!=
"x"
]]
;
then
STICKER_STATUS
=
"
`
__yellow Updated
`
"
if
[
"x
$UNDER_MIGRATION
"
=
"xyes"
]
;
then
STICKER_STATUS
=
"
`
__magenta Migrated
`
"
else
STICKER_STATUS
=
"
`
__yellow Updated
`
"
fi
sed
-i
"/[0-9a-f]
\{
32
\}
$FILE
/d"
$SUM_FILE
sed
-i
"/[0-9a-f]
\{
32
\}
$FILE
/d"
$SUM_FILE
else
else
STICKER_STATUS
=
"
`
__green New
`
"
STICKER_STATUS
=
"
`
__green New
`
"
...
@@ -901,9 +907,62 @@ __pack() {
...
@@ -901,9 +907,62 @@ __pack() {
info
"Pack created, you can now commit it and create a MR to share it with other users"
info
"Pack created, you can now commit it and create a MR to share it with other users"
}
}
download_image_from_server
()
{
local
mxc_url
=
"
$1
"
local
name
=
"
$2
"
local
extension
=
"
$3
"
[
-z
"
$mxc_url
"
]
&&
die
"Missing MXC URL before downloading."
[
-z
"
$2
"
]
&&
die
"Missing name before downloading."
[
-z
"
$3
"
]
&&
die
"Missing extension before downloading."
local
filename
=
"
$name
.
$extension
"
local
folder_destination
=
"
${
4
:-
/tmp
}
"
[
!
-d
"
$folder_destination
"
]
&&
mkdir
-p
"
$folder_destination
"
local
destination
=
$(
printf
"%s/%s
\n
"
"
${
folder_destination
%/
}
"
"
${
filename
#/
}
"
)
echo
$destination
# Ideally, we'd check if the MXC is valid. Too lazy for a one-shot script.
local hostname
=
"
${
mxc_url
#*
://
}
"
hostname
=
"
${
hostname
%%/*
}
"
local id
=
"
${
mxc_url
##*/
}
"
curl
"https://
$STPKG_HOMESERV
/_matrix/client/v1/media/download/
$hostname
/
$id
/"
-H
"Authorization: Bearer
$STPKG_TOKEN
"
-o
$destination
}
# Allows to migrate stickers from a pack to the current homeserver
# Re-downloads the sticker images from their current server, and re-uploads to the new one
__migrate
()
{
local
pack_name
=
"
$1
"
[
"x
$pack_name
"
=
"x"
]
&&
die
"You must specify a pack for the 'migrate' command"
local
FILE
=
"
${
STPKG_INSTALL
}
/web/packs/
$pack_name
.json"
[
!
-r
"
$FILE
"
]
&&
die
"Pack '
$pack_name
' is not available (check with 'pack list'). The corresponding file should be '
$FILE
'"
echo
"Migrate the sticker pack
$(
__green
`
jq
'.title'
<
"
$FILE
"
`
)
:"
if
[
"x
$STPKG_TOKEN
"
=
"x"
]
;
then
read
-sp
"
`
__yellow
'Enter your access token:'
`
"
STPKG_TOKEN
validate_token
# Validate token, will exit if invalid
fi
local
temporary_destination
=
"/tmp/
$pack_name
"
jq
'.stickers[] | "\(.body) \(.url) \(.info.mimetype)"'
<
"
$FILE
"
|
while
IFS
=
read
LINE
;
do
local
NAME
=
`
echo
"
$LINE
"
|
awk
-F
'"| '
'{print $2}'
`
local
URL
=
`
echo
"
$LINE
"
|
awk
-F
'"| '
'{print $3}'
`
local
TYPE
=
`
echo
"
$LINE
"
|
awk
-F
'"| '
'{print $4}'
|
awk
-F
'/'
'{print $2}'
`
download_image_from_server
$URL
$NAME
$TYPE
$temporary_destination
done
UNDER_MIGRATION
=
"yes"
STPKG_REUPLOAD_SAME_FILE
=
"yes"
__pack
$pack_name
$temporary_destination
}
__do_command
()
{
__do_command
()
{
case
"
$1
"
in
case
"
$1
"
in
show|update|list|add|del|default|pack|display|edit
)
show|update|list|add|del|default|pack|display|edit
|migrate
)
# Source conf file, may have the sshfs hook
# Source conf file, may have the sshfs hook
if
[
-f
$STPKG_CONF_FILE
]
;
then
if
[
-f
$STPKG_CONF_FILE
]
;
then
source
$STPKG_CONF_FILE
source
$STPKG_CONF_FILE
...
@@ -1032,5 +1091,6 @@ case "$1" in
...
@@ -1032,5 +1091,6 @@ case "$1" in
pack
)
shift
;
__do_command pack
$*
;;
pack
)
shift
;
__do_command pack
$*
;;
display
)
shift
;
__do_command display
$*
;;
display
)
shift
;
__do_command display
$*
;;
edit
)
shift
;
__do_command edit
$*
;;
edit
)
shift
;
__do_command edit
$*
;;
migrate
)
shift
;
__do_command migrate
$*
;;
*
)
__do_command usage
;;
*
)
__do_command usage
;;
esac
esac
Ce diff est replié.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter