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 conteneurs
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é GitLab
Contribuer à GitLab
Donner votre avis
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
Elliu
matrix-stickers
Validations
3cff0da2
Valider
3cff0da2
rédigé
Il y a 4 ans
par
Miryuni
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
Added check test on homeserver and token
parent
7df02c4f
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Modifications
1
Afficher les modifications d'espaces
En ligne
Côte à côte
Affichage de
1 fichier modifié
matrixpack.sh
+58
-8
58 ajouts, 8 suppressions
matrixpack.sh
avec
58 ajouts
et
8 suppressions
matrixpack.sh
+
58
−
8
Voir le fichier @
3cff0da2
...
@@ -32,22 +32,72 @@ if test $# -lt 3 ; then
...
@@ -32,22 +32,72 @@ if test $# -lt 3 ; then
exit
1
exit
1
fi
fi
for
i
in
"
$@
"
# Display usage funtion
do
display_usage
(){
if
[
-d
"
$i
"
]
;
then
echo
-e
"
\n
Usage : ./matrixpack.sh token homeserver directory
\n
"
}
# Changing directory to work directly in it
# Erase http:// or https:// if added in the homeserver
cd
"
$i
"
slug_homeserver
()
{
echo
"
$1
"
| iconv
-c
-t
ascii//TRANSLIT |
sed
-E
's/^http:\/\/|^https:\/\///g'
|
sed
-E
's/^-+|-+$//g'
}
# Checking params
if
test
$#
-lt
3
;
then
echo
1>&2
"
$0
:FATAL: invalid argument number (expected 3)"
display_usage
exit
1
fi
# Checking if ImageMagick is installed
if
!
command
-v
convert &> /dev/null
&&
!
command
-v
montage &> /dev/null
;
then
echo
"
$0
:ERROR: ImageMagick could not be found"
exit
fi
# Setting variables
# Setting variables
dir
=
$(
pwd
)
dir
=
$(
pwd
)
token
=
$1
token
=
$1
packname
=
${
dir
##*/
}
packname
=
${
dir
##*/
}
slug
=
$(
slugify
"
$packname
"
)
slug
=
$(
slugify
"
$packname
"
)
homeserver
=
$2
homeserver
=
$(
slug_homeserver
$2
)
# Checking if the homeserver exist
curl
"https://
$homeserver
"
-I
-o
headers
-s
if
test
-f
"headers"
;
then
rm
headers
else
echo
1>&2
"
$0
:FATAL: The homeserver
\"
$2
\"
is not correct."
exit
1
fi
# Checking if the token exist
curl
-s
-X
POST
"https://
$homeserver
/_matrix/media/r0/upload?access_token=
$token
"
| python3
-c
"import sys, json; print(json.load(sys.stdin)['errcode'])"
>>
headers
while
read
line
;
do
if
[[
(
$line
==
"M_UNKNOWN"
)
]]
then
rm
headers
else if
[[
(
$line
==
"M_UNKNOWN_TOKEN"
)
]]
then
echo
"
$0
:ERROR: The token provided does not exist"
rm
headers
exit
1
else
echo
"
$0
:ERROR: Not yet implemented error"
exit
1
fi
fi
done
< headers
for
i
in
"
$@
"
do
if
[
-d
"
$i
"
]
;
then
# Changing directory to work directly in it
cd
"
$i
"
# Printing informations
# Printing informations
echo
-e
"Creating sticker pack
\0
33[94;1m
$packname
\0
33[0m
\n
homeserver=
\0
33[94m
$homeserver
\0
33[0m
\n
output=
\0
33[94m
$slug
\0
33[0m"
echo
-e
"Creating sticker pack
:
\0
33[94;1m
$packname
\0
33[0m
\n
homeserver=
\0
33[94m
$homeserver
\0
33[0m
\n
output=
\0
33[94m
$slug
\0
33[0m"
# Making result folder
# Making result folder
if
!
[
-d
$slug
]
;
then
mkdir
$slug
;
fi
if
!
[
-d
$slug
]
;
then
mkdir
$slug
;
fi
...
...
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