Merci d’avoir pris le temps. Cela s’exécute bien mais le echo est mis après le “}” et non juste avant du coup je pense que la config sera foireuse tel que. Mais en tout cas ça s’execute bien.
Dans ce cas remplace echo par sed.
Plusieurs solutions selon comment est fait ton fichier. Si le “}” est en fin de fichier comme je crois le comprendre, tu peux essayer ceci:
C’est étonnant, je viens de tester et ça fonctionne bien comme je l’ai indiqué avec un fichier de test semblable.
N’aurais-tu pas oublié le i? Dans ce cas le 1er “A” de allow est considéré comme l’option append de sed et le bloc se place à la fin mais la 1ère ligne serait en plus tronquée, il manquerait le “A” sur allow.
Ta solution fonctionne évidemment mais uniquement s’il y a un seul } dans le fichier. Si ce n’était pas le cas, tu ajouterais le bloc allow/deny avant chaque }.
J’ai copié collé tel que ton message, j’ai testé deux fois quand même au cas ou et il m’a bien collé le texte à la suite. C’est pour ça que je me suis orienté ailleurs. Mais merci de m’avoir orienté sur SED ;).
Le fichier de JF comporte qu’un seul “}” donc pas dérangeant dans le cas présent ;).
Hi All, I have a hook script /etc/yunohost/hooks.d/conf_regen/01_ssh_stream_local_bind_unlink
When I run yunohost tools regen-conf ssh -f the setting does not get applied. I have made the sure conf_regen directory and the script are executable. Any tips?
#!/bin/bash
# This should allow forwarding ssh and gpg keys.
# It is supposed to append StreamLocalBindUnlink yes
# in the ssh user tunnelling section
action=$1
pending_dir=$4
ssh_conf=$pending_dir/../ssh/etc/ssh/sshd_config
[[ "$action" == "pre" ]] || exit 0
[[ -e $ssh_conf ]] || exit 0
sed -i '/PermitUserRC yes/a StreamLocalBindUnlink yes' $ssh_conf
Changed it like this : 04-ssh_streamlocalbindunlink
the number is the priority of the hook. Look in the folder /usr/share/yunohost/hooks/conf_regen , you see a default hook 03-ssh. If you give a smaller number, this hook is execute after yours and overwrite your modifications.
With a bigger number, your hook execute after the default one and the modifications can be applied.
I suggest you to read the link i post in the first message of this topic to understand how to create a hook.
Thank you, that was the missing step. I understand better how the hook system works. I passed over the links in your first post since they are in French.
A hook that allows accessing ldap externally via TLS
#!/bin/bash
action=$1
pending_dir=$4
etc_default_slapd=$pending_dir/../slapd/etc/default/slapd
etc_ldap_ldap_conf=$pending_dir/../slapd/etc/ldap/ldap.conf
[[ "$action" == "pre" ]] || exit 0
[[ -e $etc_default_slapd ]] || exit 0
[[ -e $etc_ldap_ldap_conf ]] || exit 0
# from https://stackoverflow.com/a/50624719 matches the second occurence
# the hook gods don't seem to like this one so I will just replace all occurrences
# sed -i ':a;N$!ba;s/ldaps:\/\/\//ldaps:\/\/10.10.2.19:636\//2' $etc_default_slapd
sed -i 's/ldaps:\/\/\//ldaps:\/\/10.10.2.19:636\//g' $etc_default_slapd
# from https://stackoverflow.com/a/9591835
sed -i '/ldap:\/\/localhost:389/ s/$/ ldaps:\/\/10.10.2.19:636/' $etc_ldap_ldap_conf
Est il possible de créer des Hooks afin de répondre à la demande du site https://www.smtp2go.com/ pour valider des " Verified Senders" avec 2 CNAME pour un nom de domaine en noho.st par exemple ?
Is it possible to create Hooks in order to meet the request of the https://www.smtp2go.com/ site to validate “Verified Senders” with 2 CNAME for a domain name in noho.st for example?