mirror of
https://github.com/YunoHost/doc.git
synced 2024-09-03 20:06:26 +02:00
61 lines
2.7 KiB
Markdown
61 lines
2.7 KiB
Markdown
|
<a class="btn btn-lg btn-default" href="packaging_apps_fr">Packaging d’application</a>
|
|||
|
|
|||
|
## Les scripts
|
|||
|
|
|||
|
Un paquet YunoHost doit contenir cinq scripts Shell : `install`, `remove`, `upgrade`, `backup` et `restore`.
|
|||
|
Ces scripts seront exécutés en tant qu’`admin` sur les serveurs YunoHost.
|
|||
|
|
|||
|
Voici un exemple de script d’`install`:
|
|||
|
```bash
|
|||
|
# Retrieve arguments
|
|||
|
domain=$1
|
|||
|
path=$2
|
|||
|
|
|||
|
# Check domain/path availability
|
|||
|
sudo yunohost app checkurl $domain$path -a roundcube
|
|||
|
if [[ ! $? -eq 0 ]]; then
|
|||
|
exit 1
|
|||
|
fi
|
|||
|
|
|||
|
# Generate random DES key & password
|
|||
|
deskey=$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | tr -c -d '[A-Za-z0-9]' | sed -n 's/\(.\{24\}\).*/\1/p')
|
|||
|
db_pwd=$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | tr -c -d '[A-Za-z0-9]' | sed -n 's/\(.\{24\}\).*/\1/p')
|
|||
|
|
|||
|
# Use 'roundcube' as database name and user
|
|||
|
db_user=roundcube
|
|||
|
|
|||
|
# Initialize database and store mysql password for upgrade
|
|||
|
sudo yunohost app initdb $db_user -p $db_pwd -s $(readlink -e ../sources/SQL/mysql.initial.sql)
|
|||
|
sudo yunohost app setting roundcube mysqlpwd -v $db_pwd
|
|||
|
|
|||
|
# Copy files to the right place
|
|||
|
final_path=/var/www/roundcube
|
|||
|
sudo mkdir -p $final_path
|
|||
|
sudo cp -a ../sources/* $final_path
|
|||
|
sudo cp ../conf/main.inc.php $final_path/config/
|
|||
|
sudo cp ../conf/db.inc.php $final_path/config/
|
|||
|
sudo mv $final_path/plugins/managesieve/config.inc.php.dist $final_path/plugins/managesieve/config.inc.php
|
|||
|
|
|||
|
# Change variables in Roundcube configuration
|
|||
|
sudo sed -i "s/rcmail-ynhDESkeyTOchange/$deskey/g" $final_path/config/main.inc.php
|
|||
|
sudo sed -i "s/yunouser/$db_user/g" $final_path/config/db.inc.php
|
|||
|
sudo sed -i "s/yunopass/$db_pwd/g" $final_path/config/db.inc.php
|
|||
|
sudo sed -i "s/yunobase/$db_user/g" $final_path/config/db.inc.php
|
|||
|
|
|||
|
# Set permissions to roundcube directory
|
|||
|
sudo chown -R www-data: $final_path
|
|||
|
|
|||
|
# Modify Nginx configuration file and copy it to Nginx conf directory
|
|||
|
sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf
|
|||
|
sed -i "s@ALIASTOCHANGE@$final_path/@g" ../conf/nginx.conf
|
|||
|
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/roundcube.conf
|
|||
|
|
|||
|
# Reload Nginx and regenerate SSOwat conf
|
|||
|
sudo service nginx reload
|
|||
|
sudo yunohost app ssowatconf
|
|||
|
```
|
|||
|
|
|||
|
### Utilisation
|
|||
|
Vous devez tout mettre dans le script d’`install` pour que votre application soit entièrement installée. Cela signifie que vous devez installer les dépendances, créer les répertoires requis, initialiser les bases de donnés nécessaires, copier les sources et configurer tout dans l’unique script `install` (et bien sûr faire la procédure inverse dans le script `remove`).
|
|||
|
|
|||
|
**Attention** : pour des raisons de sécurité, le script est exécuté en tant qu’**admin** dans YunoHost. Assurez-vous de l’essayer en tant qu’**admin** et de préfixer `sudo` aux commandes requises.
|