From be2aae7d4e8f086e42fc0320652ef17270e121bf Mon Sep 17 00:00:00 2001 From: Julien Malik Date: Wed, 24 Aug 2016 19:33:06 +0200 Subject: [PATCH] Upgrade to PrivateBin (maintained fork) --- scripts/_common | 17 +++++++++++++++++ scripts/install | 5 ++++- scripts/upgrade | 15 ++++++++++++--- 3 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 scripts/_common diff --git a/scripts/_common b/scripts/_common new file mode 100644 index 0000000..6707ea5 --- /dev/null +++ b/scripts/_common @@ -0,0 +1,17 @@ +PRIVATEBIN_VERSION="0.22" +PRIVATEBIN_SOURCE_URL="https://github.com/PrivateBin/PrivateBin/archive/${PRIVATEBIN_VERSION}.tar.gz" +PRIVATEBIN_SOURCE_SHA256="cde40cf24af63e6908abbfff021c739258e99d1405d104992fc70f33adbadc25" + +extract_source() { + local DESTDIR=$1 + + # retrieve and extract Roundcube tarball + rc_tarball="${DESTDIR}/privatebin.tar.gz" + sudo wget -q -O "$rc_tarball" "$PRIVATEBIN_SOURCE_URL" \ + || ynh_die "Unable to download source tarball" + echo "$PRIVATEBIN_SOURCE_SHA256 $rc_tarball" | sha256sum -c >/dev/null \ + || ynh_die "Invalid checksum of downloaded tarball" + sudo tar xf "$rc_tarball" -C "$DESTDIR" --strip-components 1 \ + || ynh_die "Unable to extract source tarball" + sudo rm "$rc_tarball" +} diff --git a/scripts/install b/scripts/install index ac625fc..95993db 100644 --- a/scripts/install +++ b/scripts/install @@ -1,5 +1,8 @@ #!/bin/bash +source /usr/share/yunohost/helpers +source ./_common + # Retrieve arguments domain=$1 path=$2 @@ -19,7 +22,7 @@ fi # Copy files to the right place final_path=/var/www/zerobin sudo mkdir -p $final_path -sudo cp -a ../sources/* $final_path +extract_source $final_path # Files owned by root, www-data can just read sudo find $final_path -type f | xargs sudo chmod 644 diff --git a/scripts/upgrade b/scripts/upgrade index f112454..3bbb239 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,5 +1,8 @@ #!/bin/bash +source /usr/share/yunohost/helpers +source ./_common + domain=$(sudo yunohost app setting zerobin domain) path=$(sudo yunohost app setting zerobin path) is_public=$(sudo yunohost app setting zerobin is_public) @@ -9,10 +12,16 @@ if [[ ! "$path" == "/" ]]; then path=${path%/} fi -# Copy files to the right place +# Init final_path, if ever it got deleted somehow final_path=/var/www/zerobin sudo mkdir -p $final_path -sudo cp -a ../sources/* $final_path + +# Clean up +# This will remove old paste data (otherwise we would need to lower down security) +sudo rm -rf $final_path/* + +# Copy files to the right place +extract_source $final_path # Files owned by root, www-data can just read sudo find $final_path -type f | xargs sudo chmod 644 @@ -20,7 +29,7 @@ sudo find $final_path -type d | xargs sudo chmod 755 sudo chown -R root: $final_path # except for data and tmp subdir, where www-data must have write permissions -sudo chown www-data:root $final_path/{data,tmp} +sudo chown -R www-data:root $final_path/{data,tmp} sudo chmod 700 $final_path/{data,tmp} # Modify Nginx configuration file and copy it to Nginx conf directory