1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/syncthing_ynh.git synced 2024-09-03 20:26:23 +02:00

ajout du support de processeur

This commit is contained in:
Lahire BIETTE 2015-03-26 16:51:01 +01:00
parent b77ff2d17d
commit f0d7593d5b

View file

@ -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 $?