diff --git a/.gitignore b/.gitignore index 67221f5e4f8e8261f956b3cafc4c3153143a7053..8482dc23055376f41c80d2cd3cf868102e204d6c 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ nbproject gpg/diaspora-development/*.gpg gpg/diaspora-production/*.gpg gpg/*/random_seed +patches-* public/uploads/* public/source.tar tmp/**/* diff --git a/pkg/fedora/diaspora.spec b/pkg/fedora/diaspora.spec index 0d07ddb432d0e57a03ba42bfdf2b79bfacad6c75..ba2456a4367793fe5abf4296ab4bbc77d45f248f 100644 --- a/pkg/fedora/diaspora.spec +++ b/pkg/fedora/diaspora.spec @@ -34,6 +34,10 @@ find . -perm /u+x -type f -exec \ %build rm -rf master/vendor/bundle +<<<<<<< HEAD +mkdir master/tmp || : +======= +>>>>>>> upstream/master %install rm -fr $RPM_BUILD_ROOT @@ -55,7 +59,14 @@ cp %SOURCE3 $RPM_BUILD_ROOT/%{_sysconfdir}/logrotate.d/diaspora mkdir -p $RPM_BUILD_ROOT/%{_datadir}/diaspora cp -ar master $RPM_BUILD_ROOT/%{_datadir}/diaspora +<<<<<<< HEAD +cp -ar master/.bundle $RPM_BUILD_ROOT/%{_datadir}/diaspora/master +cp diaspora-setup $RPM_BUILD_ROOT/%{_datadir}/diaspora +mkdir -p $RPM_BUILD_ROOT/%{_localstatedir}/lib/diaspora/uploads +mkdir -p $RPM_BUILD_ROOT/%{_localstatedir}/lib/diaspora/tmp +======= cp %SOURCE2 $RPM_BUILD_ROOT/%{_datadir}/diaspora +>>>>>>> upstream/master mkdir -p $RPM_BUILD_ROOT/%{_localstatedir}/log/diaspora mkdir -p $RPM_BUILD_ROOT/%{_localstatedir}/lib/diaspora/uploads @@ -80,8 +91,25 @@ sed -i -e '\|.*/master/config.ru"$|d' \ %post +<<<<<<< HEAD +rm -f %{_datadir}/diaspora/master/vendor/bundle +rm -f %{_datadir}/diaspora/master/log +rm -f %{_datadir}/diaspora/master/public/uploads +rm -rf %{_datadir}/diaspora/master/tmp + +ln -s %{_localstatedir}/log/diaspora \ + %{_datadir}/diaspora/master/log || : +ln -s %{_libdir}/diaspora-bundle/master/vendor/bundle \ + %{_datadir}/diaspora/master/vendor || : +ln -s %{_localstatedir}/lib/diaspora/uploads \ + %{_datadir}/diaspora/master/public/uploads || : +ln -s %{_localstatedir}/lib/diaspora/tmp \ + %{_datadir}/diaspora/master/tmp || : +/sbin/chkconfig --add diaspora-ws || : +======= /sbin/chkconfig --add diaspora-wsd +>>>>>>> upstream/master %preun if [ $1 -eq 0 ] ; then @@ -96,15 +124,22 @@ rm -fr $RPM_BUILD_ROOT %files -f files %defattr(-, root, root, 0755) +<<<<<<< HEAD +%doc README.md GNU-AGPL-3.0 +======= %doc AUTHORS README.md GNU-AGPL-3.0 COPYRIGHT README-Fedora.md +>>>>>>> upstream/master %attr(-, diaspora, diaspora) %{_datadir}/diaspora/master/config.ru %attr(-, diaspora, diaspora) %{_datadir}/diaspora/master/config/environment.rb %attr(-, diaspora, diaspora) %{_localstatedir}/log/diaspora %attr(-, diaspora, diaspora) %{_localstatedir}/lib/diaspora/uploads %attr(-, diaspora, diaspora) %{_localstatedir}/lib/diaspora/tmp +<<<<<<< HEAD +======= %{_datadir}/diaspora/master/tmp %{_datadir}/diaspora/master/public/uploads %{_datadir}/diaspora/master/log +>>>>>>> upstream/master %config(noreplace) %{_sysconfdir}/logrotate.d/diaspora %{_sysconfdir}/init.d/diaspora-wsd diff --git a/pkg/fedora/make-dist.sh b/pkg/fedora/make-dist.sh index 3a24635edbdb27f30bc90811fd6349a51d68d097..2ab4ccac5e08af0ea43b551f80a2e67be062da7d 100755 --- a/pkg/fedora/make-dist.sh +++ b/pkg/fedora/make-dist.sh @@ -126,8 +126,7 @@ function checkout() git clone --quiet $GIT_REPO; ( cd diaspora; - git remote add upstream \ - git://github.com/diaspora/diaspora.git + git remote add upstream $GIT_REPO for p in ../../*.patch; do git apply --whitespace=fix $p > /dev/null done &> /dev/null || : @@ -159,7 +158,6 @@ function make_src cd dist mkdir ${RELEASE_DIR}/master cp -ar diaspora/* diaspora/.git* ${RELEASE_DIR}/master - mv ${RELEASE_DIR}/master/diaspora.spec ${RELEASE_DIR} ( cd ${RELEASE_DIR}/master git show --name-only > config/gitversion @@ -168,6 +166,9 @@ function make_src find $PWD -name .git\* | xargs rm -rf rm -rf .bundle /usr/bin/patch -p1 -s <../../../add-bundle.diff + for p in ../../../*.patch; do + /usr/bin/patch -p1 -s < $p + done &> /dev/null || : ) tar czf ${RELEASE_DIR}.tar.gz ${RELEASE_DIR} && \ rm -rf ${RELEASE_DIR} @@ -203,7 +204,8 @@ function make_bundle() cd .. } echo - echo "Bundle: dist/$bundle_name.tar.gz" + echo "Repo: $GIT_REPO" + echo "Bundle: dist/$bundle_name.tar.gz" } @@ -278,9 +280,8 @@ function usage() EOF } - commit='HEAD' -while getopts ":r:c:h" opt +while getopts ":r:c:u:h" opt do case $opt in u) GIT_REPO="$OPTARG" diff --git a/pkg/ubuntu/README.md b/pkg/ubuntu/README.md new file mode 100644 index 0000000000000000000000000000000000000000..3aeaaab01d344d5a0fa68115fa60aa0032f8fc20 --- /dev/null +++ b/pkg/ubuntu/README.md @@ -0,0 +1,57 @@ +## Package-oriented install for ubuntu. + +Here are some scripts to install diaspora on Ubuntu. They are designed to +work as a first step towards packaging, but should be usable as is. + +### Synopsis + +Bootstrap the distribution from git: + git clone git://github.com/diaspora/diaspora.git + cd diaspora/pkg/ubuntu + +Install the dependencies (a good time for a coffe break) + ./diaspora-install-deps + +Create and install the diaspora bundle and application: + ./make-dist.sh bundle + sudo ./diaspora-bundle-install dist/diaspora-bundle-*.tar.gz + + ./make-dist.sh source + sudo ./diaspora-install dist/diaspora-0.0*.tar.gz + +Initiate and start the server; + sudo ./diaspora-setup + sudo su - diaspora + cd /usr/share/diaspora/master + ./script/server + +### Notes + +The application lives in /usr/share/diaspora/master. All writable areas +(log, uploads, tmp) are links to /var/lib/diaspora. The config file lives +in /etc/diaspora. All files in /usr/share are read-only, owned by root. + +The bundle lives in /usr/lib/diaspora-bundle, readonly,owned by root. +Application finds it through the patched .bundle/config in root dir. + +The user diaspora is added during install. + +The 'make-dist-source' prints a message about the version of the bundle +it needs. Normally, it doesn't change and it's a fast procedure to generate +and install the source tarball. Generating the bundle takes some time, though. + +make-dist.sh accepts arguments to get a specified commit and/or use another +repo. + +This has been tested on a Ubuntu 32-bit 10.10 , clean server. Since this +is a very small dist, the dependencies should possibly be complete. + +The diaspora-wsd is just placeholder FTM, it does **not** work. + +Please, report any problems! + + + + + + diff --git a/pkg/ubuntu/add-bundle.diff b/pkg/ubuntu/add-bundle.diff new file mode 100644 index 0000000000000000000000000000000000000000..24c0f6035d2abfa2c09a0db451a2590684f6293a --- /dev/null +++ b/pkg/ubuntu/add-bundle.diff @@ -0,0 +1,11 @@ +diff --git a/.bundle/config b/.bundle/config +new file mode 100644 +index 0000000..1c3e2ce +--- /dev/null ++++ b/.bundle/config +@@ -0,0 +1,5 @@ ++--- ++BUNDLE_FROZEN: "1" ++BUNDLE_DISABLE_SHARED_GEMS: "1" ++BUNDLE_WITHOUT: test:rdoc ++BUNDLE_PATH: vendor/bundle diff --git a/pkg/ubuntu/diaspora-bundle-install b/pkg/ubuntu/diaspora-bundle-install new file mode 100755 index 0000000000000000000000000000000000000000..caf95d4e8bb5a958c9343595abdb38ec8afc039e --- /dev/null +++ b/pkg/ubuntu/diaspora-bundle-install @@ -0,0 +1,26 @@ +#!/bin/sh + +test "$(perl -e 'print $>')" = "0" || { + echo "You need to be root to do this, giving up" + exit 2 +} + +test $# = "1" || { + echo "Usage: diaspora-bundle-install <diaspora-bundle-VERSION-RELEASE.tar.gz>" + exit 1 +} + +test -r "$1" || { + echo "Cannot open $1" + exit 2 +} + +rm -rf /usr/lib/diaspora-bundle +tar xf $1 -C /usr/lib + +cd /usr/lib +mv $(basename $1 .tar.gz) diaspora-bundle +mkdir -p /usr/share/doc/diaspora-bundle || : +cd /usr/lib/diaspora-bundle + +cp AUTHORS GNU-AGPL-3.0 COPYRIGHT /usr/share/doc/diaspora-bundle diff --git a/pkg/ubuntu/diaspora-install b/pkg/ubuntu/diaspora-install new file mode 100755 index 0000000000000000000000000000000000000000..53d09acc6ee8a4fa51de9555ee9b35ba5d1873aa --- /dev/null +++ b/pkg/ubuntu/diaspora-install @@ -0,0 +1,68 @@ +#!/bin/bash +# +# Install a fedora source package +# +# Usage diaspora-install <tar package> + +test "$(perl -e 'print $>')" = "0" || { + echo "You need to be root to do this, giving up" + exit 2 +} + +set -x + +getent group diaspora >/dev/null || groupadd -r diaspora +getent passwd diaspora >/dev/null || \ + useradd -r -g diaspora \ + -md /var/lib/diaspora \ + -s /bin/bash \ + -c "Diaspora daemon" diaspora + +sudo tar -C /usr/share -xzf $1 + +cd /usr/share; +rm -rf /usr/share/diaspora +mv $( basename $1 .tar.gz) diaspora +cd /usr/share/diaspora +find . -perm /u+x -type f -exec \ + sed -i 's|^#!/usr/local/bin/ruby|#!/usr/bin/ruby|' {} \; > /dev/null +rm -rf master/vendor/bundle master/public/uploads master/tmp master/log +sed -i '/BUNDLE_PATH/s|:.*|: /usr/lib/diaspora-bundle/bundle|' \ + master/.bundle/config + +cp master/GNU-AGPL-3.0 master/COPYRIGHT master/README.md master/AUTHORS . +cp master/config/app_config.yml.example ./app_config.yml +cp master/pkg/ubuntu/diaspora-wsd /etc/init.d + +sed -i '/^cd /s|.*|cd /usr/share/diaspora/master|' /etc/init.d/diaspora-wsd + +cp master/pkg/ubuntu/diaspora.logrotate /etc/logrotate.d/diaspora + +cp master/pkg/ubuntu/diaspora-setup . + +mkdir -p /var/log/diaspora +mkdir -p /var/lib/diaspora/uploads +mkdir -p /var/lib/diaspora/tmp +mkdir -p /etc/diaspora + +ln -sf /var/log/diaspora ./master/log +cp master/config/app_config.yml.example /etc/diaspora/app_config.yml +ln -sf /etc/diaspora/app_config.yml master/config/app_config.yml +ln -sf /var/lib/diaspora/uploads master/public/ +ln -sf /var/lib/diaspora/tmp master +ln -sf /usr/lib/diaspora-bundle/bundle master/vendor + +rm -rf /usr/share/doc/diaspora +mkdir -p /usr/share/doc/diaspora +mv AUTHORS README.md GNU-AGPL-3.0 COPYRIGHT /usr/share/doc/diaspora + +find ./ -print | xargs chown root:root +rm -rf /usr/share/doc/diaspora +mkdir /usr/share/doc/diaspora + +chown diaspora:diaspora /usr/share/diaspora/master/config.ru +chown diaspora:diaspora /usr/share/diaspora/master/config/environment.rb +chown diaspora:diaspora /var/log/diaspora +chown diaspora:diaspora /var/lib/diaspora/uploads +chown diaspora:diaspora /var/lib/diaspora/tmp +chown diaspora:diaspora /var/lib/diaspora diff --git a/pkg/ubuntu/diaspora-install-deps b/pkg/ubuntu/diaspora-install-deps new file mode 100755 index 0000000000000000000000000000000000000000..b919370d02da35d2e73d226518ac00ac6de4291d --- /dev/null +++ b/pkg/ubuntu/diaspora-install-deps @@ -0,0 +1,14 @@ +#!/bin/bash +# +# Install diaspora dependencies i. e., what apt-get will do +# +set -x + +sudo apt-get update +sudo apt-get install -qy build-essential libxslt1-dev libxml2 ruby-full mongodb \ +rake python-software-properties git imagemagick libmagick9-dev +[starts mongodb] +sudo add-apt-repository ppa:maco.m/ruby +sudo apt-get update +sudo apt-get install -qy rubygems +sudo gem install bundler --bindir /usr/local/bin diff --git a/pkg/ubuntu/diaspora-reset b/pkg/ubuntu/diaspora-reset new file mode 100755 index 0000000000000000000000000000000000000000..a5919a635d79f6d07d758814249f01a374f3d345 --- /dev/null +++ b/pkg/ubuntu/diaspora-reset @@ -0,0 +1,12 @@ +#!/bin/sh +# +# Try to revert to pristine state, deleting all users and +# configuration +# + +set -x +service mongodb stop +rm -rf /var/lib/mongodb/* +cp /usr/share/diaspora/master/config/app_config.yml.example \ + /usr/share/diaspora/master/config/app_config.yml +service mongodb start diff --git a/pkg/ubuntu/diaspora-setup b/pkg/ubuntu/diaspora-setup new file mode 100755 index 0000000000000000000000000000000000000000..56940491f1b0c683f104a69c5f459b0309855ae3 --- /dev/null +++ b/pkg/ubuntu/diaspora-setup @@ -0,0 +1,53 @@ +#!/bin/bash +# +# Do what's needed to initiate diaspora. +# + +test "$( perl -e 'print $<')" = "0" || { + echo "You need to be root to do this, giving up" + exit 2 +} + +services=$( netstat -nl | grep '[^:]:3000[ \t]') +test -n "$services" && { + echo "Warning: something is already using port 3000" + echo " $services" +} + +/usr/sbin/service mongodb start || : + +cd /usr/share/diaspora/master + +test -e config/app_config.yml || + cp config/app_config.yml.example config/app_config.yml + +if rake db:seed:dev; then + echo "Database config OK, new user tom/evankorth in place" +else + cat <<- EOF + + Database config failed. You might want to remove all db files with + 'rm -rf /var/lib/mongodb/*' and/or resetting the config file by + 'cp config/app_config.yml.example config/app_config.yml' before + making a new try. Also, make sure the mongodb server is running + e. g., using '/sbin/service mongod status'. + EOF + exit 1 +fi + +chmod 777 /var/lib/diaspora/uploads +chown -R diaspora /var/log/diaspora + +hostname=$( awk '/pod_url:/ { print $2; exit }' <config/app_config.yml) +while : ; do + echo "Current hostname is \"$hostname\"" + echo -n "Enter new hostname [$hostname] :" + read new_hostname garbage + echo -n "Use hostname \"$new_hostname\" as pod_url (Yes/No) [Yes]? :" + read yesno garbage + test "${yesno:0:1}" = 'y' -o "${yesno:0:1}" = 'Y' -o -z "$yesno" && { + sed -i "/pod_url:/s/$hostname/$new_hostname/g" config/app_config.yml && + echo "config/app_config.yml updated." + break + } +done diff --git a/pkg/ubuntu/diaspora-wsd b/pkg/ubuntu/diaspora-wsd new file mode 100755 index 0000000000000000000000000000000000000000..e80f24f6ea9d40bb9aba5a869cd6b677aec3827a --- /dev/null +++ b/pkg/ubuntu/diaspora-wsd @@ -0,0 +1,102 @@ +#!/bin/bash +# +# /etc/rc.d/init.d/diaspora-wsd +# +# SHOULD start the diaspora websocket daemon, but it doesn't. No way. +# +# chkconfig: - 80 80 +# description: Diaspora websocket daemon + +### BEGIN INIT INFO +# Provides: diaspora-wsd +# Required-Start: $local_fs $network +# Required-Stop: $local_fs $network +# Should-Start: $remote_fs +# Should-Stop: $remote_fs +# Default-Start: +# Default-Stop: 0 1 2 3 4 5 6 +# Short-Description: start and stop Diaspora websocket server +# Description: The websocket server provides websocket services for +# diaspora. +### END INIT INFO + +# Source function library. +. /etc/init.d/functions + +if [ -f /etc/sysconfig/diaspora-wsd -a $UID -eq 0 ]; then + . /etc/sysconfig/diaspora-wsd +fi + +# Note: this line is patched by installation scripts. +cd /usr/share/diaspora + +RETVAL=0 +prog="Diaspora websocket server" +exec="script/websocket_server.rb" +pidfile="/var/run/diaspora-wsd" +lockfile="/var/lock/subsys/diaspora-wsd" +logfile=/var/log/diaspora-wsd.log + +[ -n "$OPTIONS" ] && OPTIONS=" $OPTIONS" +ruby_cmd="ruby -C $PWD $exec$OPTIONS" + +start() { + [ $UID -eq 0 ] || exit 4 + [ -f $exec ] || exit 5 + + echo -n $"Starting $prog: " + daemon --pidfile $pidfile "$ruby_cmd >>$logfile 2>&1 &" + RETVAL=$? + echo + if test $RETVAL = 0; then + touch $lockfile + pgrep -f "$ruby_cmd" > $pidfile || { + echo "Warning: cannot find running diaspora-webserver" + exit 7 + } + fi +} + +stop() { + [ $UID -eq 0 ] || exit 4 + echo -n $"Stopping $prog: " + killproc -p $pidfile $exec + RETVAL=$? + [ $RETVAL -eq 0 ] && rm -f $lockfile + echo +} + +# +# See how we were called. +# +case "$1" in + start) + start + ;; + stop) + stop + ;; + force-reload|restart) + stop + sleep 1 + start + RETVAL=$? + ;; + condrestart|try-restart) + if [ -f $lockfile ]; then + stop + sleep 3 + start + fi + ;; + status) + status -p $pidfile $exec + RETVAL=$? + ;; + *) + echo $"Usage: $0 {condrestart|try-restart|start|stop|restart|force-reload|status}" + RETVAL=2 + [ "$1" = 'usage' ] && RETVAL=0 +esac + +exit $RETVAL diff --git a/pkg/ubuntu/diaspora.logrotate b/pkg/ubuntu/diaspora.logrotate new file mode 100644 index 0000000000000000000000000000000000000000..28f158d2c3ee21239521064429b287c23a07e266 --- /dev/null +++ b/pkg/ubuntu/diaspora.logrotate @@ -0,0 +1,13 @@ +/var/log/diaspora/*.log { + create 755 diaspora diaspora + weekly + rotate 10 + copytruncate + delaycompress + compress + notifempty + missingok + postrotate + ( /sbin/service diaspora-wsd condrestart ) >/dev/null 2>&1 + endscript +} diff --git a/pkg/ubuntu/make-dist.sh b/pkg/ubuntu/make-dist.sh new file mode 120000 index 0000000000000000000000000000000000000000..f6ba9c6a20bea49e9b411387ee8ec36f9c748582 --- /dev/null +++ b/pkg/ubuntu/make-dist.sh @@ -0,0 +1 @@ +../fedora/make-dist.sh \ No newline at end of file