Outils personnels
Vous êtes ici : Accueil GNU / Linux Debian Installer Mozilla Sync Server sur Debian
Actions sur le document
  • Send this page to somebody
  • Print this page
  • Add Bookmarklet

Installer Mozilla Sync Server sur Debian

Par Pierre-Yves Landuré - Dernière modification 03/05/2011 18:54

Mozilla Sync Server est un outil permettant de synchroniser plusieurs installations de Mozilla Firefox. Cet outil était à l'origine appelé Mozilla Weave Server. Ce guide vous aide à l'installer sur Debian.

Ce guide a été testé sur :

  • Debian 6.0 Squeeze

Pré-requis

Ce guide nécessite un serveur MySQL disposant du script mysql-tools disponible dans le guide Installer et configurer MySQL sur Debian.

Ce guide nécessite un serveur Apache 2 avec support du PHP disposant du script a2tools disponible dans mon guide Installer Apache 2 sur Debian.

Important : Pour fonctionner correctement, Mozilla Sync requiert que le serveur Apache 2 soit configuré pour gérer le protocole HTTPS.

Paramètres

Renseignez le nom de domaine ou sera disponible l'application :

DOMAIN="mozsync.domaine-exemple.fr"

Renseignez le nom d'hôte de votre serveur MySQL (si vous ne savez pas de quoi il s'agit, ne modifiez pas cette valeur) :

MYSQL_HOST="localhost"

Si votre serveur MySQL n'est pas local, ce guide effectuera une connexion SSH pour y créer la base de données.

Installation

Installez les modules PHP nécessaires au bon fonctionnement de l'application :

command apt-get install bzip2 php5-mysql mysql-client apg

Créez le dossier destiné à contenir l'installation de l'application :

command mkdir --parent "/opt/${DOMAIN}/public"

Mozilla Sync est composé de 2 éléments distincts :

  • reg-server qui se charge de l'enregistrement des utilisateurs.
  • sync-server qui se charge de la synchronisation avec Mozilla Firefox.

Création de la base de données

Créez la base de données de reg-serveur :

if [ "${MYSQL_HOST}" = "localhost" ]; then
  MYSQL_PARAMS=$(command mysql-tools create-domain-db "${DOMAIN}")
else
  command echo "Saisissez le mot de passe de l'utilisateur root MySQL :"
  command read PASSWORD
  MYSQL_PARAMS=$(command ssh "root@${MYSQL_HOST}" "command mysql-tools create-domain-db '${DOMAIN}' '$(command cat /etc/mailname)' '${PASSWORD}'")
fi

Récupérez les paramètres de la nouvelle base de données :

MYSQL_DB="$(echo "${MYSQL_PARAMS}" | command grep -e "^MYSQL_DB" \
    | cut --delimiter="=" --fields="2-")"
MYSQL_USER="$(echo "${MYSQL_PARAMS}" | command grep -e "^MYSQL_USER" \
    | cut --delimiter="=" --fields="2-")"
MYSQL_PASSWORD="$(echo "${MYSQL_PARAMS}" | command grep -e "^MYSQL_PASSWORD" \
    | cut --delimiter="=" --fields="2-")"
echo "${MYSQL_PARAMS}"

Initialisez le contenu de la base de données :

echo '
create table users (
 id int(11) NOT NULL PRIMARY KEY auto_increment,
 username varchar(32),
 password_hash varbinary(128),
 email varbinary(64),
 status tinyint(4) default '1',
 alert text,
 reset varbinary(32) default null,
 reset_expiration datetime
) engine=InnoDB;

CREATE TABLE `collections` (
  `userid` int(11) NOT NULL,
  `collectionid` smallint(6) NOT NULL,
  `name` varchar(32) NOT NULL,
  PRIMARY KEY  (`userid`,`collectionid`),
  KEY `nameindex` (`userid`,`name`)
) ENGINE=InnoDB;

CREATE TABLE `wbo` (
  `username` int(11) NOT NULL,
  `collection` smallint(6) NOT NULL default '\''0'\'',
  `id` varbinary(64) NOT NULL default '\'\'',
  `parentid` varbinary(64) default NULL,
  `predecessorid` varbinary(64) default NULL,
  `sortindex` int(11) default NULL,
  `modified` bigint(20) default NULL,
  `payload` longtext,
  `payload_size` int(11) default NULL,
  `ttl` int(11) default '\''2100000000'\'',
  PRIMARY KEY  (`username`,`collection`,`id`),
  KEY `parentindex` (`username`,`collection`,`parentid`),
  KEY `modified` (`username`,`collection`,`modified`),
  KEY `weightindex` (`username`,`collection`,`sortindex`),
  KEY `predecessorindex` (`username`,`collection`,`predecessorid`),
  KEY `size_index` (`username`,`payload_size`)
) ENGINE=InnoDB;
'  | command mysql --user="${MYSQL_USER}" --password="${MYSQL_PASSWORD}" \
    --host="${MYSQL_HOST}" "${MYSQL_DB}"

Installation de reg-server

Récupérez le numéro du dernier tag de reg-server :

REVISION="$(command wget --quiet --output-document=- \
    "http://hg.mozilla.org/services/reg-server/" \
    | command grep --max-count=1 '>changeset<' \
    | command cut --delimiter='|' --fields=1  \
    | command sed -e 's|^.*href="\([^"]*\)".*$|\1|' \
    | command cut --delimiter='/' --fields=5)"

Téléchargez les sources :

command wget "http://hg.mozilla.org/services/reg-server/archive/${REVISION}.tar.bz2" \
    --output-document="/tmp/reg-server-${REVISION}.tar.bz2"

Décompressez l'archive :

command tar --directory='/tmp' -xjf "/tmp/reg-server-${REVISION}.tar.bz2"

Déplacez les sources vers leur emplacement final :

command mv "/tmp/reg-server-${REVISION}" "/opt/${DOMAIN}/reg-server"

Créez le fichier de configuration :

command cp "/opt/${DOMAIN}/reg-server/1.0/weave_user_constants.php.dist" \
    "/opt/${DOMAIN}/reg-server/1.0/weave_user_constants.php"

Générez un mot de passe d'administration (Notez précieusement le mot de passe affiché) :

ADMIN_PASSWORD="$(command apg -q -a  0 -n 1 -M NCL)"
echo "${ADMIN_PASSWORD}"

Configurez l'application :

command sed -i \
    -e "s|^\(.*'WEAVE_AUTH_ENGINE', '\)[^']*\(.*\)\$|\1mysql\2|" \
    -e "s|^\(.*'WEAVE_MYSQL_AUTH_HOST', '\)[^']*\(.*\)\$|\1${MYSQL_HOST}\2|" \
    -e "s|^\(.*'WEAVE_MYSQL_AUTH_DB', '\)[^']*\(.*\)\$|\1${MYSQL_DB}\2|" \
    -e "s|^\(.*'WEAVE_MYSQL_AUTH_USER', '\)[^']*\(.*\)\$|\1${MYSQL_USER}\2|" \
    -e "s|^\(.*'WEAVE_MYSQL_AUTH_PASS', '\)[^']*\(.*\)\$|\1${MYSQL_PASSWORD}\2|" \
    -e "s/^[#]*\(.*'WEAVE_REGISTER_ADMIN_SECRET', \)null\(.*\)\$/\1'${ADMIN_PASSWORD}'\2/" \
    -e "s|^[#]*\(.*'WEAVE_SHA_SALT', '\)[^']*\(.*\)\$|\1$(command apg -m 63 -x 63 -n 1 -a 1 -M SNCL -E "'\"|/&\\")\2|" \
    -e "s|^[#]*\(.*'WEAVE_PASSWORD_RESET_EMAIL', '\)[^']*\(.*\)\$|\1no-reply@${DOMAIN}\2|" \
  "/opt/${DOMAIN}/reg-server/1.0/weave_user_constants.php"

Supprimez l'archive téléchargée :

command rm "/tmp/reg-server-${REVISION}.tar.bz2"

Installation de sync-server

Récupérez le numéro du dernier tag de sync-server :

REVISION="$(command wget --quiet --output-document=- \
    "http://hg.mozilla.org/services/sync-server/" \
    | command grep --max-count=1 '>changeset<' \
    | command cut --delimiter='|' --fields=1  \
    | command sed -e 's|^.*href="\([^"]*\)".*$|\1|' \
    | command cut --delimiter='/' --fields=5)"

Téléchargez les sources :

command wget "http://hg.mozilla.org/services/sync-server/archive/${REVISION}.tar.bz2" \
    --output-document="/tmp/sync-server-${REVISION}.tar.bz2"

Décompressez l'archive :

command tar --directory='/tmp' -xjf "/tmp/sync-server-${REVISION}.tar.bz2"

Déplacez les sources vers leur emplacement final :

command mv "/tmp/sync-server-${REVISION}" "/opt/${DOMAIN}/sync-server"

Récupérez la configuration du sync-server :

MYSQL_AUTH_HOST="$(command cat "/opt/${DOMAIN}/reg-server/1.0/weave_user_constants.php" \
    | command grep "WEAVE_MYSQL_AUTH_HOST" \
    | command sed -e "s|^.*, '\([^']*\)'.*\$|\1|")"
MYSQL_AUTH_DB="$(command cat "/opt/${DOMAIN}/reg-server/1.0/weave_user_constants.php" \
    | command grep "WEAVE_MYSQL_AUTH_DB" \
    | command sed -e "s|^.*, '\([^']*\)'.*\$|\1|")"
MYSQL_AUTH_USER="$(command cat "/opt/${DOMAIN}/reg-server/1.0/weave_user_constants.php" \
    | command grep "WEAVE_MYSQL_AUTH_USER" \
    | command sed -e "s|^.*, '\([^']*\)'.*\$|\1|")"
MYSQL_AUTH_PASSWORD="$(command cat "/opt/${DOMAIN}/reg-server/1.0/weave_user_constants.php" \
    | command grep "WEAVE_MYSQL_AUTH_PASS" \
    | command sed -e "s|^.*, '\([^']*\)'.*\$|\1|")"
WEAVE_SHA_SALT="$(command cat "/opt/${DOMAIN}/reg-server/1.0/weave_user_constants.php" \
    | command grep "WEAVE_SHA_SALT" \
    | command sed -e "s|^.*, '\([^']*\)'.*\$|\1|")"

Créez le fichier de configuration :

command cp "/opt/${DOMAIN}/sync-server/1.1/default_constants.php.dist" \
    "/opt/${DOMAIN}/sync-server/1.1/default_constants.php"

Configurez l'application :

command sed -i \
    -e "s|^\(.*'WEAVE_STORAGE_ENGINE', '\)[^']*\(.*\)\$|\1mysql\2|" \
    -e "s|^\(.*'WEAVE_MYSQL_STORE_READ_HOST', '\)[^']*\(.*\)\$|\1${MYSQL_HOST}\2|" \
    -e "s|^\(.*'WEAVE_MYSQL_STORE_READ_DB', '\)[^']*\(.*\)\$|\1${MYSQL_DB}\2|" \
    -e "s|^\(.*'WEAVE_MYSQL_STORE_READ_USER', '\)[^']*\(.*\)\$|\1${MYSQL_USER}\2|" \
    -e "s|^\(.*'WEAVE_MYSQL_STORE_READ_PASS', '\)[^']*\(.*\)\$|\1${MYSQL_PASSWORD}\2|" \
    -e "s|^\(.*'WEAVE_AUTH_ENGINE', '\)[^']*\(.*\)\$|\1mysql\2|" \
    -e "s|^\(.*'WEAVE_MYSQL_AUTH_HOST', '\)[^']*\(.*\)\$|\1${MYSQL_AUTH_HOST}\2|" \
    -e "s|^\(.*'WEAVE_MYSQL_AUTH_DB', '\)[^']*\(.*\)\$|\1${MYSQL_AUTH_DB}\2|" \
    -e "s|^\(.*'WEAVE_MYSQL_AUTH_USER', '\)[^']*\(.*\)\$|\1${MYSQL_AUTH_USER}\2|" \
    -e "s|^\(.*'WEAVE_MYSQL_AUTH_PASS', '\)[^']*\(.*\)\$|\1${MYSQL_AUTH_PASSWORD}\2|" \
    -e "s|^\([ \t]*\)[#]*\(.*'WEAVE_SHA_SALT', '\)[^']*\(.*\)\$|\1\2${WEAVE_SHA_SALT}\3|" \
 "/opt/${DOMAIN}/sync-server/1.1/default_constants.php"

Afin de corriger un bug dans le serveur, commentez une ligne d'erreur :

command sed -i \
    -e 's|.*no standard locale available.*|//&|' \
    -e 's|.*Database Unavailable.*|//&|' \
  "/opt/${DOMAIN}/sync-server/1.1/weave_user/mysql.php"

Supprimez l'archive téléchargée :

command rm "/tmp/sync-server-${REVISION}.tar.bz2"

Configuration du serveur HTTP

Mettez en place la configuration Apache 2 adéquate à l'aide de a2tools :

command a2tools add-ssl-custom "${DOMAIN}" "
  DocumentRoot /opt/${DOMAIN}/public/

  <Directory \"/opt/${DOMAIN}/\">
    Options Indexes FollowSymLinks
    AllowOverride none
    Order allow,deny
    Allow from all
  </Directory>

  Alias /1.0 /opt/${DOMAIN}/sync-server/1.1/index.php
  Alias /user/1.0 /opt/${DOMAIN}/reg-server/1.0/index.php
  Alias /user/1 /opt/${DOMAIN}/reg-server/1.0/index.php
  Alias /misc/1.0/captcha_html /opt/${DOMAIN}/reg-server/1.0/captcha.php
  Alias /weave-registration-static /opt/${DOMAIN}/reg-server/1.0/static
  Alias /weave-password-reset /opt/${DOMAIN}/reg-server/1.0/forgot_password.php
" /etc/apache2/ssl/key.pem /etc/apache2/ssl/cert.pem

Rappel : Mozilla Sync Server nécessite une connexion HTTPS, d'où la nécessiter de disposer d'un certificat SSL (key.pem et cert.pem).

Utilisation

En premier lieu, ajoutez à Mozilla Firefox l'extension :

Important : A partir de Mozilla Firefox 4.0, Sync est intégré directement dans le navigateur. L'installation de l'extension devient inutile.

Une fois l'extension installée :

  1. allez dans le menu "Outils -> Set up Sync",
  2. cliquez sur le bouton "Créer un nouveau compte",
  3. Renseignez vos informations personnelles,
  4. Pour l'option Serveur, choisissez l'option "Utiliser un serveur personnalisé".
  5. Dans le champ "URL du serveur", saisissez l'adresse de votre serveur (par exemple : https://mozsync.domaine-exemple.fr),
  6. Cliquez sur "Suivant",
  7. Notez précieusement la clef de synchronisation qui vous est alors affichée.
  8. Cliquez sur "Suivant",
  9. Cliquez sur "Terminer".

Vous disposez maintenant d'un compte sur votre serveur Mozilla Sync.

Grâce à la clef de synchronisation, vous pouvez synchroniser plusieurs ordinateurs, vous retrouverez ainsi favoris, et mots de passe enregistrés sur tous vos ordinateurs.

Remerciements

BlogBang
Navigation
 

Réalisé avec Plone

Ce site respecte les normes suivantes :

Wikio