From f0d7593d5b1dea4a0ac04c641d2ac258e7caa37f Mon Sep 17 00:00:00 2001 From: Lahire BIETTE Date: Thu, 26 Mar 2015 16:51:01 +0100 Subject: [PATCH] ajout du support de processeur --- scripts/install | 136 +++++++++++++++++++++++++----------------------- 1 file changed, 71 insertions(+), 65 deletions(-) diff --git a/scripts/install b/scripts/install index 1820e08..0fe933c 100644 --- a/scripts/install +++ b/scripts/install @@ -1,65 +1,71 @@ -#!/bin/bash - -# Retrieve arguments -domain=$1 -path=$2 - -# Configurable variables -syncVersion="0.10.29" -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-amd64-v$syncVersion.tar.gz -O /tmp/syncthing.tar.gz -sudo tar -C /tmp -xvf /tmp/syncthing.tar.gz syncthing-linux-amd64-v$syncVersion/syncthing -sudo mv /tmp/syncthing-linux-amd64-v$syncVersion/syncthing $syncHome/bin/syncthing -sudo chown $syncUser: $syncHome/bin/syncthing -sudo chmod 640 $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" +elif [ "$arch" = "i686"] ; then + syncArch="386" +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 640 $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 $?