Browse Source

sympa_ldap

main
pvincent 3 weeks ago
parent
commit
0c8cc036d8
  1. 5
      .vscode/extensions.json
  2. 21
      .vscode/settings.json
  3. 3
      README.md
  4. 15
      TODO.md
  5. 4
      run_task_in_parrallel.sh
  6. 26
      sympa/TODO.md
  7. 13
      sympa/bin/apply_auth_remote_ssh.bash
  8. 133
      sympa/bin/import.bash
  9. 27
      sympa/bin/install_zourit_style.bash
  10. 8
      sympa/doc/custom_cemea.md
  11. 69
      sympa/miaou/miaou-install-sympa
  12. 60
      sympa/recipe/install.bash
  13. 95
      sympa/recipe/sympa.recipe
  14. 57
      sympa/recipe/sympa_custom_style.recipe
  15. 18
      sympa/recipe/sympa_ldap_auth_remote.recipe
  16. 0
      sympa/resources/tools/sympa_export.bash
  17. 132
      sympa/resources/tools/sympa_import.bash
  18. 0
      sympa/resources/tools/sympa_purge.bash
  19. 1
      unavailable.txt

5
.vscode/extensions.json

@ -0,0 +1,5 @@
{
"recommendations": [
"jgclark.vscode-todo-highlight"
]
}

21
.vscode/settings.json

@ -1,3 +1,22 @@
{
"editor.formatOnSave": true
"editor.formatOnSave": true,
"files.associations": {
"*.recipe": "shellscript"
},
"todohighlight.include": [
"**/*.js",
"**/*.jsx",
"**/*.ts",
"**/*.tsx",
"**/*.html",
"**/*.css",
"**/*.scss",
"**/*.php",
"**/*.rb",
"**/*.txt",
"**/*.mdown",
"**/*.md",
"**/sympa/miaou/*",
"**/*.sh"
]
}

3
README.md

@ -20,4 +20,5 @@
* [install](sympa/install.md)
* [migration](sympa/migration.md)
change #1

15
TODO.md

@ -0,0 +1,15 @@
TODO
====
* [ ] prévenir la possibilité de lancer un script .recipe sur le hôte
* [ ] tester la version Debian13 avec une IP fixe
* [ ] configurer postfix conformément à la version Debian9
* [ ] migrer une ancienne version de liste de Debian 9 vers la version Debian 13
* [ ] déplacement massif de toutes les anciennes listes
* [ ] scripter
Documentation
-------------
* [install](sympa/doc/installation.md)
* [migration](sympa/doc/migration.md)

4
run_task_in_parrallel.sh

@ -3,5 +3,5 @@
FILE=listes.txt
TASK=$1
echo > unavailable.txt
parallel -a "$FILE" "$TASK"
echo >unavailable.txt
parallel -a "$FILE" "$TASK"

26
sympa/TODO.md

@ -1,26 +0,0 @@
TODO
====
* [x] tester bon fonctionnement d'une ancienne liste à base de Debian9
* [x] listes.artcode.re
* [x] tenir à jour [listes.txt](../listes.txt)
* [x] listes.voyagesdegulliver.fr EFFACÉ
* [ ] listes.bonneveine2.com ??? à ajouter après DNS ok ?
* [x] installer un Sympa sur une base Debian 12 récente
* [x] souci avec nginx
* [x] systemd cgi issue
* [x] réessayer apache2
* [x] ok
* [x] réessayer avec nginx
* [x] correction de l'installation
* [ ] tester la version Debian12 avec une IP fixe
* [ ] configurer postfix conformément à la version Debian9
* [ ] migrer une ancienne version de liste de Debian 9 vers la version Debian 12
* [ ] déplacement massif de toutes les anciennes listes
* [ ] scripter
Documentation
-------------
* [install](install.md)
* [migration](doc/migration.md)

13
sympa/bin/apply_auth_remote_ssh.bash

@ -1,13 +0,0 @@
#!/usr/bin/env bash
# changes in /etc/sympa/auth.conf
sed -i 's/.*host 192.168.1.254:389.*/ host 127.0.0.1:3890 # remote connection through SSH/' /etc/sympa/auth.conf
# start SSH port translation if needed
if ! ss -tln | grep -q 127.0.0.1:3890; then
ssh -fN listes.artcode.re -L 3890:192.168.1.254:389
echo 'SSH port translation 3890 is now active!'
systemctl restart wwsympa.socket
else
echo 'SSH already enabled!'
fi

133
sympa/bin/import.bash

@ -1,133 +0,0 @@
#!/usr/bin/env bash
## constants
BASEDIR=$(dirname "$0")
BASECMD=$(basename "$0")
DB_NAME=sympa
DB_USER="$DB_NAME"
DB_PASS="$DB_NAME"
## functions
function usage {
echo "$BASECMD <file.sympa>"
}
function assert_file {
[[ $# != 1 ]] && usage && exit 1
file="$1"
[[ ! -f $file ]] && echo "file not found: $file" && exit 2
true
}
function create_temp {
echo -n "create_temp..."
export_name=$(basename $file)
export_tmp="/tmp/$export_name"
mkdir "$export_tmp"
echo OK
}
function uncompress_export_file {
echo -n "uncompress export file..."
tar -xf $file -C "$export_tmp"
echo OK
}
function import_database {
echo -n "import database $DB_NAME..."
sudo -u postgres dropdb "$DB_NAME" 2>/dev/null
sudo -u postgres createdb -O "$DB_USER" "$DB_NAME" 2>/dev/null
gunzip -c "$export_tmp"/database.psql.gz | PGPASSWORD="$DB_PASS" psql -h localhost -U "$DB_USER" "$DB_NAME"
echo OK
}
function replace_conf_entry_from_export {
local export_conf=etc/sympa/sympa/sympa.conf
local final_conf="/$export_conf"
local key="$1"
local pattern="^$key.*"
local replacement=$(grep $pattern $export_conf)
local ksh93=${replacement//\//\\/}
sed -i "s/$pattern/$ksh93/" "$final_conf"
}
function import_files_etc {
mv etc/sympa/auth.conf /etc/sympa/
mv etc/sympa/data_structure.version /etc/sympa/
replace_conf_entry_from_export domain
replace_conf_entry_from_export listmaster
replace_conf_entry_from_export wwsympa_url
replace_conf_entry_from_export lang
}
function import_files_lib {
rm -rf /var/lib/sympa
mv var/lib/sympa /var/lib
}
function import_files_spool {
rm -rf /var/spool/sympa
mv var/spool/sympa /var/spool
}
function import_files {
echo -n "import files..."
files_temp="$export_tmp/files"
mkdir "$files_temp"
cd "$files_temp"
tar -xf "$export_tmp/files.tar.gz"
import_files_etc
import_files_lib
import_files_spool
echo OK
}
function migrate_sympa {
echo -n "migrate sympa..."
/usr/lib/sympa/bin/sympa.pl upgrade 2>&1
echo OK
}
function stop_services {
echo -n "stop services..."
sudo systemctl stop sympa.service
sudo systemctl stop wwsympa.socket
echo OK
}
function start_services {
echo -n "start services..."
sudo systemctl start sympa.service
sudo systemctl start wwsympa.socket
echo OK
}
function remove_temp {
echo -n "remove temp..."
rm -rf "$export_tmp"
echo OK
}
function import {
create_temp
uncompress_export_file
stop_services
import_database
import_files
start_services
migrate_sympa
remove_temp
}
## main
set -Eeu
assert_file $*
import

27
sympa/bin/install_zourit_style.bash

@ -1,27 +0,0 @@
#!/usr/bin/env bash
# changes in /usr/share/sympa/lib/Sympa/Config/Schema.pm
sed -i "s/.*005ab2.*/ default => '#ad0c78', # '#005ab2' replaced by ZOURIT-COLOR-1/" /usr/share/sympa/lib/Sympa/Config/Schema.pm
sed -i "s/.*004b94.*/ default => '#1f2937', # '#004b94' replaced by ZOURIT-COLOR-2/" /usr/share/sympa/lib/Sympa/Config/Schema.pm
sed -i "s/.*0090e9.*/ default => '#b15593', # '#0090e9' replaced by ZOURIT-COLOR-3/" /usr/share/sympa/lib/Sympa/Config/Schema.pm
sed -i "s/.*66aaff.*/ default => '#949ba7', # '#66aaff' replaced by ZOURIT-COLOR-4/" /usr/share/sympa/lib/Sympa/Config/Schema.pm
# changes in /usr/share/sympa/default/web_tt2/css.tt2
if ! grep -q '.top-bar button:hover' /usr/share/sympa/default/web_tt2/css.tt2; then
sed -i "1661i\\.top-bar button:hover{\\n color: white;\\n}" /usr/share/sympa/default/web_tt2/css.tt2
echo 'style changed successfully'
else
echo 'style already changed!'
fi
# detect if exists inherited list styles
socket_restart=false
for i in /var/lib/sympa/css/*; do
if [[ "$i" != '/var/lib/sympa/css/style.css' ]] && [[ -d "$i" ]]; then
socket_restart=true
rm -rf "$i"
fi
done
[[ $socket_restart == true ]] && systemctl restart wwsympa.socket && echo "wwsympa restarted with fresh styles"
true

8
sympa/doc/custom_cemea.md

@ -8,10 +8,10 @@ CUSTOM CEMEA's styling
* append_or_replace... # TODO: use append_or_replace!
```
default =>'#ad0c78', # '#005ab2' replaced by ZOURIT-COLOR-1
default =>'#b15593', # '#004b94' replaced by ZOURIT-COLOR-2
default =>'#1f2937', # '#0090e9', replaced by ZOURIT-COLOR-3
default =>'#949ba7', # '#66aaff', replaced by ZOURIT-COLOR-4
default =>'#b15593', # '#004b94' SYMPA_COLOR_1
default =>'#ad0c78', # '#005ab2' SYMPA_COLOR_2
default =>'#1f2937', # '#0090e9' SYMPA_COLOR_3
default =>'#949ba7', # '#66aaff' SYMPA_COLOR_4
```
then `systemctl restart wwsympa.socket`

69
sympa/miaou/miaou-install-sympa

@ -0,0 +1,69 @@
#!/usr/bin/env bash
# CONSTANTS
BASEDIR=$(dirname "$0")
CONTAINER=''
# FUNCTIONS
function usage {
echo "$(basename "$0") <CONTAINER_NAME>"
}
function parse_options {
while [[ $# -gt 0 ]]; do
case "$1" in
--help | -h)
usage && exit 0
;;
*)
if [[ -z $CONTAINER ]]; then
CONTAINER=$1
else
echo >&2 "Unknown option: $1" && usage && exit 2
fi
;;
esac
shift 1 # Move to the next argument
done
[[ -n $CONTAINER ]] || (usage && exit 1)
}
function assert_miaou_server {
[[ -d /opt/miaou-incus ]] ||
[[ -d /opt/miaou-proxmox ]] ||
(>&2 echo 'ERROR: either miaou-{incus,proxmox} must be installed on this host prior running this command!' && exit 10)
}
function assert_fake_sympa {
[[ $(fqdn) == 'topcode' ]] && [[ -d /opt/miaou-incus ]]
}
function install_sympa_tools {
for file in "$BASEDIR"/../resources/tools/*; do
miaou-push $CONTAINER $file /opt/miaou-sympa/tools/
done
miaou-exec $CONTAINER -- ln -sf /usr/lib/sympa/bin/sympa.pl /opt/miaou-sympa/tools/
}
function install_fake_additional {
assert_fake_sympa || return
echo 'install fake additional TODO: not yet functional...'
# miaou-push $CONTAINER $HOME/.ssh/id_ed25519 /root/.ssh/
# miaou-push $CONTAINER $HOME/.ssh/id_ed25519.pub /root/.ssh/
# miaou-recipe "$CONTAINER" "$BASEDIR"/../recipe/sympa_ldap_auth_remote.recipe
}
# MAIN
set -Eue
parse_options $*
assert_miaou_server
miaou-recipe "$CONTAINER" "$BASEDIR"/../recipe/sympa.recipe
miaou-recipe "$CONTAINER" "$BASEDIR"/../recipe/sympa_custom_style.recipe
install_sympa_tools
install_fake_additional

60
sympa/recipe/install.bash

@ -1,60 +0,0 @@
#!/usr/bin/env bash
# postfix
debconf-set-selections <<EOF
postfix postfix/mailname string $(hostname -f)
postfix postfix/main_mailer_type string 'Internet Site'
postfix postfix/mynetworks string '127.0.0.0/8'
EOF
DEBIAN_FRONTEND=noninteractive apt install -y postfix postgresql nginx fcgiwrap perl-doc micro debconf-utils
postconf -e "inet_protocols = ipv4"
systemctl restart postfix
# sympa
listmasters="pvincent@artcode.re,jnoel@mithril.re"
[[ $(hostname -d) == *.* ]] && listmasters+=",listmaster@$(hostname -d)" || true
debconf-set-selections <<EOF
sympa wwsympa/webserver_type select 'Other'
sympa sympa/database-type string pgsql
sympa sympa/db_host string localhost
sympa sympa/db_name string sympa
sympa sympa/db_user string sympa
sympa sympa/db_pass password sympa
sympa sympa/language select fr
sympa sympa/listmaster string $listmasters
EOF
DEBIAN_FRONTEND=noninteractive apt install -y sympa
systemctl disable sympasoap.{socket,service}
systemctl stop sympasoap.{socket,service}
# nginx
cat <<EOF >/etc/nginx/sites-available/sympa.conf
server {
listen 80;
server_name _;
rewrite ^/$ /wws permanent;
location /wws {
include fastcgi_params;
fastcgi_param SERVER_NAME $(hostname -f);
fastcgi_pass unix:/run/sympa/wwsympa.socket;
}
location /static-sympa {
alias /usr/share/sympa/static_content;
}
location /css-sympa {
alias /var/lib/sympa/css;
}
location /pictures-sympa {
alias /var/lib/sympa/pictures;
}
}
EOF
cd /etc/nginx/sites-enabled && rm -f default && ln -sf ../sites-available/sympa.conf && cd
systemctl reload nginx
# final word
echo Sympa successfully installed!

95
sympa/recipe/sympa.recipe

@ -0,0 +1,95 @@
#!/usr/bin/env miaou-recipe
# CONSTANTS
FORCE=${FORCE:-false}
# FUNCTIONS
function install_postfix {
if $FORCE || ! systemctl is-active postfix.service --quiet; then
debconf-set-selections <<EOF
postfix postfix/mailname string $(hostname -f)
postfix postfix/main_mailer_type string 'Internet Site'
postfix postfix/mynetworks string '127.0.0.0/8'
EOF
DEBIAN_FRONTEND=noninteractive apt-get install -y postfix postgresql nginx fcgiwrap perl-doc micro debconf-utils
postconf -e "inet_protocols = ipv4"
systemctl restart postfix
echo postfix installed successfully!
else
echo postfix already installed!
fi
}
function alter_sympa_postgres_password_to {
password="$1"
/opt/miaou-bash/tools/append_or_replace '^db_passwd.*' "db_passwd\tsympa" /etc/sympa/sympa/sympa.conf
sudo -u postgres -- psql -c "ALTER USER sympa PASSWORD '$password'"
systemctl restart wwsympa.service
}
function install_sympa {
if $FORCE || ! systemctl is-active wwsympa.service --quiet; then
listmasters="pvincent@artcode.re,jnoel@mithril.re"
[[ $(hostname -d) == *.* ]] && listmasters+=",listmaster@$(hostname -d)" || true
debconf-set-selections <<EOF
sympa wwsympa/webserver_type select 'Other'
sympa sympa/database-type string pgsql
sympa sympa/db_host string localhost
sympa sympa/db_name string sympa
sympa sympa/db_user string sympa
sympa sympa/language select fr
sympa sympa/listmaster string $listmasters
EOF
DEBIAN_FRONTEND=noninteractive apt-get install -y sympa
systemctl disable sympasoap.{socket,service}
systemctl stop sympasoap.{socket,service}
alter_sympa_postgres_password_to sympa
echo sympa.service installed successfully!
else
echo sympa.service already installed!
fi
}
function install_nginx_host {
if $FORCE || [[ ! -f /etc/nginx/sites-available/sympa.conf ]]; then
cat <<EOF >/etc/nginx/sites-available/sympa.conf
server {
listen 80;
server_name _;
rewrite ^/$ /wws permanent;
location /wws {
include fastcgi_params;
fastcgi_param SERVER_NAME $(hostname -f);
fastcgi_pass unix:/run/sympa/wwsympa.socket;
}
location /static-sympa {
alias /usr/share/sympa/static_content;
}
location /css-sympa {
alias /var/lib/sympa/css;
}
location /pictures-sympa {
alias /var/lib/sympa/pictures;
}
}
EOF
cd /etc/nginx/sites-enabled && rm -f default && ln -sf ../sites-available/sympa.conf && cd
systemctl reload nginx
echo host for nginx installed successfully!
else
echo host for nginx already installed!
fi
}
# MAIN
install_postfix
install_sympa
install_nginx_host

57
sympa/recipe/sympa_custom_style.recipe

@ -0,0 +1,57 @@
#!/usr/bin/env miaou-recipe
# CONSTANTS
SYMPA_GENERATOR=/usr/share/sympa/lib/Sympa/WWW/Tools.pm
SYMPA_CSS=/usr/share/sympa/default/web_tt2/css.tt2
# FUNCTIONS
function override_topbar {
if ! grep -q '.top-bar button:hover' "$SYMPA_CSS"; then
sed -i "1661i\\.top-bar button:hover{\\n color: white;\\n}" "$SYMPA_CSS"
echo 'topbar changed successfully'
fi
}
function apply_theme {
local fqdn=$(hostname -f)
[[ $fqdn == *cemea* ]] && apply_cemea_style || apply_zourit_style
}
function apply_cemea_style {
sed -i "s/.*005ab2.*/\t\tdefault => '#000000', # '#005ab2' replaced by CEMEA-COLOR-1/" "$SYMPA_GENERATOR"
sed -i "s/.*004b94.*/\t\tdefault => '#e30613', # '#004b94' replaced by CEMEA-COLOR-2/" "$SYMPA_GENERATOR"
sed -i "s/.*0090e9.*/\t\tdefault => '#184857', # '#0090e9' replaced by CEMEA-COLOR-3/" "$SYMPA_GENERATOR"
sed -i "s/.*66aaff.*/\t\tdefault => '#00a19a', # '#66aaff' replaced by CEMEA-COLOR-4/" "$SYMPA_GENERATOR"
echo "CEMEA style applied successfully!"
}
function apply_zourit_style {
sed -i "s/.*005ab2.*/\t\tdefault => '#ad0c78', # '#005ab2' replaced by ZOURIT-COLOR-1/" "$SYMPA_GENERATOR"
sed -i "s/.*004b94.*/\t\tdefault => '#1f2937', # '#004b94' replaced by ZOURIT-COLOR-2/" "$SYMPA_GENERATOR"
sed -i "s/.*0090e9.*/\t\tdefault => '#535786', # '#0090e9' replaced by ZOURIT-COLOR-3/" "$SYMPA_GENERATOR"
sed -i "s/.*66aaff.*/\t\tdefault => '#949ba7', # '#66aaff' replaced by ZOURIT-COLOR-4/" "$SYMPA_GENERATOR"
echo "ZOURIT style applied successfully!"
}
function clear_custom_styles {
for i in /var/lib/sympa/css/*; do
if [[ "$i" != '/var/lib/sympa/css/style.css' ]] && [[ -d "$i" ]]; then
rm -rf "$i"
echo "customized style: $i removed!"
fi
done
}
function refresh_style {
systemctl restart wwsympa.socket
}
# MAIN
set -Eue
override_topbar
apply_theme
clear_custom_styles
refresh_style

18
sympa/recipe/sympa_ldap_auth_remote.recipe

@ -0,0 +1,18 @@
#!/usr/bin/env miaou-recipe
# changes in /etc/sympa/auth.conf
if grep -q '.*host 192.168.1.254:389.*' /etc/sympa/auth.conf; then
/opt/miaou-bash/tools/append_or_replace '.*host 192.168.1.254:389.*' "\thost 127.0.0.1:3890" /etc/sympa/auth.conf
echo 'sympa auth from LDAP local 127.0.0.1:3890 is now active'
else
echo 'sympa auth from LDAP local 127.0.0.1:3890 already enabled'
fi
# start SSH port translation if needed
if ! ss -tln | grep -q 127.0.0.1:3890; then
ssh -fN listes.artcode.re -L 3890:192.168.1.254:389
echo 'SSH port translation 3890 is now active!'
systemctl restart wwsympa.socket
else
echo 'SSH already enabled!'
fi

0
sympa/bin/export.bash → sympa/resources/tools/sympa_export.bash

132
sympa/resources/tools/sympa_import.bash

@ -0,0 +1,132 @@
#!/usr/bin/env bash
## constants
BASEDIR=$(dirname "$0")
BASECMD=$(basename "$0")
DB_NAME=sympa
DB_USER="$DB_NAME"
DB_PASS="$DB_NAME"
## functions
function usage {
echo "$BASECMD <file.sympa>"
}
function assert_file {
[[ $# != 1 ]] && usage && exit 1
file="$1"
[[ ! -f $file ]] && echo "file not found: $file" && exit 2
true
}
function create_temp {
echo -n "create_temp..."
export_name=$(basename $file)
export_tmp="/tmp/$export_name"
mkdir "$export_tmp"
echo OK
}
function uncompress_export_file {
echo -n "uncompress export file..."
tar -xf $file -C "$export_tmp"
echo OK
}
function import_database {
echo -n "import database $DB_NAME..."
sudo -u postgres dropdb "$DB_NAME" 2>/dev/null
sudo -u postgres createdb -O "$DB_USER" "$DB_NAME" 2>/dev/null
gunzip -c "$export_tmp"/database.psql.gz | PGPASSWORD="$DB_PASS" psql -h localhost -U "$DB_USER" "$DB_NAME"
echo OK
}
function replace_conf_entry_from_export {
local export_conf=etc/sympa/sympa/sympa.conf
local final_conf="/$export_conf"
local key="$1"
local pattern="^$key.*"
local replacement=$(grep $pattern $export_conf)
local ksh93=${replacement//\//\\/}
sed -i "s/$pattern/$ksh93/" "$final_conf"
}
function import_files_etc {
mv etc/sympa/auth.conf /etc/sympa/
mv etc/sympa/data_structure.version /etc/sympa/
replace_conf_entry_from_export domain
replace_conf_entry_from_export listmaster
replace_conf_entry_from_export lang
}
function import_files_lib {
rm -rf /var/lib/sympa
mv var/lib/sympa /var/lib
}
function import_files_spool {
rm -rf /var/spool/sympa
mv var/spool/sympa /var/spool
}
function import_files {
echo -n "import files..."
files_temp="$export_tmp/files"
mkdir "$files_temp"
cd "$files_temp"
tar -xf "$export_tmp/files.tar.gz"
import_files_etc
import_files_lib
import_files_spool
echo OK
}
function migrate_sympa {
echo -n "migrate sympa..."
/usr/lib/sympa/bin/sympa.pl upgrade 2>&1
echo OK
}
function stop_services {
echo -n "stop services..."
sudo systemctl stop sympa.service
sudo systemctl stop wwsympa.socket
echo OK
}
function start_services {
echo -n "start services..."
sudo systemctl start sympa.service
sudo systemctl start wwsympa.socket
echo OK
}
function remove_temp {
echo -n "remove temp..."
rm -rf "$export_tmp"
echo OK
}
function import {
create_temp
uncompress_export_file
stop_services
import_database
import_files
start_services
migrate_sympa
remove_temp
}
## main
set -Eeu
assert_file $*
import

0
sympa/bin/purge.bash → sympa/resources/tools/sympa_purge.bash

1
unavailable.txt

@ -1 +0,0 @@
Loading…
Cancel
Save