From c95b46258b12ef2999d44ed544d5f1faea67ec8c Mon Sep 17 00:00:00 2001 From: Lahire Biette Date: Thu, 26 Mar 2015 17:36:28 +0100 Subject: [PATCH] correction de bug --- scripts/install | 150 ++++++++++++++++++++++++------------------------ 1 file changed, 75 insertions(+), 75 deletions(-) diff --git a/scripts/install b/scripts/install index 4b1a8d5..889a274 100644 --- a/scripts/install +++ b/scripts/install @@ -1,75 +1,75 @@ -#!/bin/bash - -# Retrieve arguments -domain=$1 -path=$2 - -# Configurable variables -syncVersion="0.10.29" -arch=`uname -m` -if [ "$arch" = "x86_64" ] ; then - syncArch="amd64" -fi -if [ "$arch" = "i386" ] || [ "$arch" == "i686" ] ; then - syncArch="386" -fi -if [ "$arch" = "arm" ] ; then - syncArch="arm" -fi -syncHome="/home/yunohost.syncthing" -syncUser=debian-syncthing -syncSyncport=22000 -syncUIport=8080 - - -sudo yunohost app checkurl $domain$path -a syncthing -if [[ ! $? -eq 0 ]]; then - exit 1 -fi - -# Remove trailing "/" for next commands -path=${path%/} - -# Check port availability -sudo yunohost app checkport $syncUIport -if [[ ! $? -eq 0 ]]; then - exit 1 -fi -sudo yunohost app checkport $syncSyncport -if [[ ! $? -eq 0 ]]; then - exit 1 -fi - -# Open port in firewall -sudo yunohost firewall allow TCP $syncSyncport > /dev/null 2>&1 - -# Create $syncUser user to syncthing service -sudo useradd -m -d $syncHome/ -s /bin/false $syncUser - -# Make directories and set rights -sudo mkdir -p $syncHome/{bin,sync} -sudo chown -R $syncUser:$syncUser $syncHome/ -sudo find $syncHome/ -type f | while read LINE; do sudo chmod 640 "$LINE" ; done -sudo find $syncHome/ -type d | while read LINE; do sudo chmod 750 "$LINE" ; done - -# Download and install syncthing binary -sudo wget https://github.com/syncthing/syncthing/releases/download/v$syncVersion/syncthing-linux-$syncArch-v$syncVersion.tar.gz -O /tmp/syncthing.tar.gz -sudo tar -C /tmp -xvf /tmp/syncthing.tar.gz syncthing-linux-$syncArch-v$syncVersion/syncthing -sudo mv /tmp/syncthing-linux-$syncArch-v$syncVersion/syncthing $syncHome/bin/syncthing -sudo chown $syncUser: $syncHome/bin/syncthing -sudo chmod 750 $syncHome/bin/syncthing - -# Install and monitor service -# les deux lignes ci dessous si il s'avère nécessaire de créer un script sysinit -# sudo cp ../conf/syncthingd /etc/init.d/syncthingd -# sudo update-rc.d syncthingd defaults -sudo apt-get install runit -y -qq -sudo mkdir -p /etc/service/syncthing -sudo cp -R ../conf/run ../conf/log /etc/service/syncthing -sudo yunohost service add runit - -# Configure Nginx and reload -sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf -sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/syncthing.conf -sudo service nginx reload -echo $? +#!/bin/bash + +# Retrieve arguments +domain=$1 +path=$2 + +# Configurable variables +syncVersion="0.10.29" +arch=`uname -m` +if [ "$arch" = "x86_64" ] ; then + syncArch="amd64" +fi +if [ "$arch" = "i386" ] || [ "$arch" == "i686" ] ; then + syncArch="386" +fi +if [ "$arch" = "arm" ] ; then + syncArch="arm" +fi +syncHome="/home/yunohost.syncthing" +syncUser=debian-syncthing +syncSyncport=22000 +syncUIport=8080 + + +sudo yunohost app checkurl $domain$path -a syncthing +if [[ ! $? -eq 0 ]]; then + exit 1 +fi + +# Remove trailing "/" for next commands +path=${path%/} + +# Check port availability +sudo yunohost app checkport $syncUIport +if [[ ! $? -eq 0 ]]; then + exit 1 +fi +sudo yunohost app checkport $syncSyncport +if [[ ! $? -eq 0 ]]; then + exit 1 +fi + +# Open port in firewall +sudo yunohost firewall allow TCP $syncSyncport > /dev/null 2>&1 + +# Create $syncUser user to syncthing service +sudo useradd -m -d $syncHome/ -s /bin/false $syncUser + +# Make directories and set rights +sudo mkdir -p $syncHome/{bin,sync} +sudo chown -R $syncUser:$syncUser $syncHome/ +sudo find $syncHome/ -type f | while read LINE; do sudo chmod 640 "$LINE" ; done +sudo find $syncHome/ -type d | while read LINE; do sudo chmod 750 "$LINE" ; done + +# Download and install syncthing binary +sudo wget https://github.com/syncthing/syncthing/releases/download/v$syncVersion/syncthing-linux-$syncArch-v$syncVersion.tar.gz -O /tmp/syncthing.tar.gz +sudo tar -C /tmp -xvf /tmp/syncthing.tar.gz syncthing-linux-$syncArch-v$syncVersion/syncthing +sudo mv /tmp/syncthing-linux-$syncArch-v$syncVersion/syncthing $syncHome/bin/syncthing +sudo chown $syncUser: $syncHome/bin/syncthing +sudo chmod 750 $syncHome/bin/syncthing + +# Install and monitor service +# les deux lignes ci dessous si il s'avère nécessaire de créer un script sysinit +# sudo cp ../conf/syncthingd /etc/init.d/syncthingd +# sudo update-rc.d syncthingd defaults +sudo apt-get install runit -y -qq +sudo mkdir -p /etc/service/syncthing +sudo cp -R ../conf/run ../conf/log /etc/service/syncthing +sudo yunohost service add runit + +# Configure Nginx and reload +sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf +sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/syncthing.conf +sudo service nginx reload +echo $?