From 3c9a921631271b72b2b2efb7435ee721d7a7b338 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Thu, 11 Sep 2014 12:51:51 +0200 Subject: [PATCH] FHS compliance - BREAKING COMMIT --- Backend/etcinitd/etcinitd-swarmops-backend | 2 +- BuildFiles/Packaging/repackage | 48 ++++--- BuildFiles/Packaging/repackage.save | 122 ------------------ BuildFiles/Packaging/repository | 1 - .../templates/conffiles-frontend.template | 4 +- .../templates/postinst-backend.template | 3 +- .../templates/postinst-frontend.template | 2 +- Logic/Support/Document.cs | 4 +- Site5/Automation/UploadFileHandler.ashx | 2 +- .../v5/Ledgers/ResyncExternalAccount.aspx.cs | 4 +- Site5/Pages/v5/Support/StreamUpload.aspx.cs | 4 +- Utility/BotCode/BotLog.cs | 2 +- 12 files changed, 44 insertions(+), 154 deletions(-) delete mode 100755 BuildFiles/Packaging/repackage.save delete mode 120000 BuildFiles/Packaging/repository diff --git a/Backend/etcinitd/etcinitd-swarmops-backend b/Backend/etcinitd/etcinitd-swarmops-backend index 83b290cc..f258540b 100644 --- a/Backend/etcinitd/etcinitd-swarmops-backend +++ b/Backend/etcinitd/etcinitd-swarmops-backend @@ -23,7 +23,7 @@ PATH=/usr/sbin:/usr/bin:/sbin:/bin DESC="Swarmops Backend" NAME=Swarmops.Backend.exe MONO=/usr/bin/mono -RUNDIR=/opt/swarmops/backend +RUNDIR=/usr/share/swarmops/backend DAEMON=$RUNDIR/$NAME DAEMON_ARGS="" PIDFILE=/var/run/$NAME.pid diff --git a/BuildFiles/Packaging/repackage b/BuildFiles/Packaging/repackage index f86a48c3..ea4572ee 100755 --- a/BuildFiles/Packaging/repackage +++ b/BuildFiles/Packaging/repackage @@ -1,5 +1,11 @@ #!/bin/bash +#Update all files, including this one. Runpos will remain same in possible new version +echo "Checking for updates to packaging..." +svn update + +DEPLOYDIR=usr/share/swarmops + # Check parameters if [ "$1" == "frontend" ]; then echo "Packaging frontend..."; @@ -57,28 +63,34 @@ cp ../lastbuild/frontend/BuildIdentity.txt ../lastbuild/backend/. # Delete flag that indicates a new drop is available #rm /home/packaging/lastbuild/BuildDropped.txt +# Remove previous package files, if any +if [ -d debian ]; then + rm -rf debian +fi + # Init build +mkdir debian +mkdir debian/DEBIAN cd debian -# Delete temporary files -echo "Removing previous package files..." -rm -rf opt/swarmops/* - -if [ -d etc ]; then - rm -rf etc -fi if [ "$COPYFILES" == "yes" ]; then echo "Copying payload files into repo..." - mkdir -p opt/swarmops/$TARGETDIR - cp -R $SOURCEDIR/* opt/swarmops/$TARGETDIR/. + mkdir -p $DEPLOYDIR/$TARGETDIR + cp -R $SOURCEDIR/* $DEPLOYDIR/$TARGETDIR/. if [ -d $SOURCEDIR/etcinitd ]; then echo "Adding /etc/init.d files..." - mkdir etc - mkdir etc/init.d + mkdir -p etc/init.d cp $SOURCEDIR/etcinitd/* etc/init.d/. fi + + if [ "$1" == "frontend" ]; then + echo "moving user-configurable files to /etc/swarmops/..." + mkdir -p etc/swarmops + mv $DEPLOYDIR/$TARGETDIR/machineKey.config etc/swarmops/. + sed -i 's/\"machineKey.config\"/\"\/etc\/swarmops\/machineKey.config\"/g' $DEPLOYDIR/$TARGETDIR/web.config + fi fi echo "Copying template files into repo..." @@ -135,13 +147,15 @@ if [ "$2" == "" ]; then dpkg -i swarmops-$PACKAGENAME-latest.deb fi +echo "Cleaning up..." + +rm swarmops-$PACKAGENAME-latest.deb +rm -rf debian + echo "Notifying developers that new build has deployed for test..." -echo "Swarmops $PACKAGENAME build $(cat $BUILDIDSOURCE | tr -d ' \r') has been deployed as daily build." > deploymsg.txt -echo "Test it at http://dev.swarmops.com/ as usual." >> deploymsg.txt -mail -s "Swarmops $PACKAGENAME $(cat $BUILDIDSOURCE) deployed" "swarmops-builds@falkvinge.net" < deploymsg.txt +echo "Swarmops $PACKAGENAME build $(cat $BUILDIDSOURCE | tr -d ' \r') has been deployed from continuous integration." > deploymsg.txt +echo "The package is available from repositories now, and can be tested at http://dev.swarmops.com/ as usual." >> deploymsg.txt +mail -F "Swarmops Builder " -s "Swarmops $PACKAGENAME $(cat $BUILDIDSOURCE | tr -d ' \r') deployed" "swarmops-builds@falkvinge.net" < deploymsg.txt rm deploymsg.txt rm $BUILDIDSOURCE - - - diff --git a/BuildFiles/Packaging/repackage.save b/BuildFiles/Packaging/repackage.save deleted file mode 100755 index dc6776cd..00000000 --- a/BuildFiles/Packaging/repackage.save +++ /dev/null @@ -1,122 +0,0 @@ -#!/bin/bash - -# Check parameters -if [ "$1" == "frontend" ]; then - echo "Packaging frontend..."; - SOURCEDIR=/home/packager/lastbuild/frontend - TARGETDIR=frontend - PACKAGE=frontend - INCLUDEDB=yes -elif [ "$1" == "backend" ]; then - echo "Packaging backend..." - SOURCEDIR=/home/packager/lastbuild/backend - TARGETDIR=backend - PACKAGE=backend - INCLUDEDB=yes -elif [ "$1" == "extscripts" ]; then - echo "Packaging external scripts..." - SOURCEDIR=/home/prod/Smallwebs/HostedScripts - TARGETDIR=frontend/Scripts/ExternalScripts - PACKAGE=external-scripts -else - echo "Syntax:" - echo "repackage {frontend|backend|extscripts} [stable]" - echo - echo "If 'stable' is not given, -internal will be added to the package name." - exit 1; -fi - -BUILDIDFILE=if not exist etcinitd\. mkdir etcinitd -copy ..\..\etcinitd\swarmops-backend etcinitd - - -if [ "$2" == "stable" ]; then - CONTROLSUFFIX=-stable - echo "Packaging STABLE for external deployment." -else - CONTROLSUFFIX=-internal - if [ "$1" == "extscripts" ]; then - echo "Error: Cannot package external scripts for internal build. Use 'stable'." - exit 1; - fi -fi - -PACKAGENAME=$PACKAGE$CONTROLSUFFIX - -# Delete flag that indicates a new drop is available -#rm /home/packaging/lastbuild/BuildDropped.txt - -# Init build -cd debian - -# Delete temporary files -echo "Removing previous package files..." -rm -rf opt/swarmops/* - -if [ -d etc ]; then - rm -rf etc -fi - -echo "Copying payload files into repo..." -mkdir -p opt/swarmops/$TARGETDIR -cp -R $SOURCEDIR/* opt/swarmops/$TARGETDIR/. - -if [ -d $SOURCEDIR/etcinitd ]; then - echo "Adding /etc/init.d files..." - mkdir etc - mkdir etc/init.d - cp $SOURCEDIR/etcinitd/* etc/init.d/. -fi - -echo "Copying template files into repo..." -if [ "$INCLUDEDB" == "yes" ]; then - cp ../templates/database.config.template opt/swarmops/$TARGETDIR/database.config -fi -cp ../templates/control-$PACKAGENAME.template DEBIAN/control -cp ../templates/conffiles-$PACKAGE.template DEBIAN/conffiles - -if [ -e "../templates/prerm-$PACKAGE.template" ]; then - echo "Adding $PACKAGE prerm script..." - cp ../templates/prerm-$PACKAGE.template DEBIAN/prerm -else - if [ -e "DEBIAN/prerm" ]; then - echo "Deleting old prerm script..." - rm DEBIAN/prerm - fi -fi - -if [ -e "../templates/postinst-$PACKAGE.template" ]; then - echo "Adding $PACKAGE postinst script..." - cp ../templates/postinst-$PACKAGE.template DEBIAN/postinst -else - if [ -e "DEBIAN/postinst" ]; then - echo "Deleting old postinst script..." - rm DEBIAN/postinst - fi -fi - -echo "Setting build number ($(cat ../../lastbuild/frontend/BuildIdentity.txt | tr -d ' \r'))..." -sed -i "s/--BuildNumber--/$(cat ../../lastbuild/frontend/BuildIdentity.txt | tr -d ' \r')/" DEBIAN/control - -# Calculating new checksums -echo "Creating MD5 checksum file..." -../scripts/create-md5 - -echo "Creating package 'swarmops-$PACKAGENAME-latest.deb'..." -cd .. -if [ -e swarmops-$PACKAGENAME-latest.deb ]; then - rm swarmops-$PACKAGENAME-latest.deb -fi -fakeroot dpkg-deb --build debian -mv debian.deb swarmops-$PACKAGENAME-latest.deb -cp swarmops-$PACKAGENAME-latest.deb /home/prod/Smallwebs/Activizr-repo - -echo "Updating repositories..." -scripts/update-repos swarmops-$PACKAGENAME-latest.deb - -echo "Notifying developers that new build has deployed for test..." -echo "Swarmops $PACKAGENAME build $(cat debian-stable/opt/swarmops/frontend/BuildIdentity.txt | tr -d ' \r') has been deployed as daily build." > deploymsg.txt -echo "Test it at http://dev.swarmops.com/ as usual." >> deploymsg.txt -mail -s "Swarmops $PACKAGENAME $(cat debian-stable/opt/swarmops/frontend/BuildIdentity.txt)deployed as daily" "swarmops-builds@falkvinge.net" < deploymsg.txt - - diff --git a/BuildFiles/Packaging/repository b/BuildFiles/Packaging/repository deleted file mode 120000 index 4ba0dd3e..00000000 --- a/BuildFiles/Packaging/repository +++ /dev/null @@ -1 +0,0 @@ -/home/prod/Smallwebs/Activizr-repo/ \ No newline at end of file diff --git a/BuildFiles/Packaging/templates/conffiles-frontend.template b/BuildFiles/Packaging/templates/conffiles-frontend.template index 60b794d2..596dca0a 100644 --- a/BuildFiles/Packaging/templates/conffiles-frontend.template +++ b/BuildFiles/Packaging/templates/conffiles-frontend.template @@ -1,2 +1,2 @@ -/opt/swarmops/frontend/machineKey.config -/opt/swarmops/frontend/favicon.ico +/etc/swarmops/machineKey.config +/usr/local/share/swarmops/frontend/favicon.ico diff --git a/BuildFiles/Packaging/templates/postinst-backend.template b/BuildFiles/Packaging/templates/postinst-backend.template index bc6bb1db..bc5e427a 100644 --- a/BuildFiles/Packaging/templates/postinst-backend.template +++ b/BuildFiles/Packaging/templates/postinst-backend.template @@ -2,8 +2,7 @@ #echo "Swarmops post-installation script running" #make sure some directories exist -mkdir -p /opt/swarmops/upload -mkdir -p /opt/swarmops/backend/logs +mkdir -p /var/lib/swarmops/upload #todo: check for database upgrade #start the daemon /etc/init.d/swarmops-backend start diff --git a/BuildFiles/Packaging/templates/postinst-frontend.template b/BuildFiles/Packaging/templates/postinst-frontend.template index dd77f8f1..d30d638b 100644 --- a/BuildFiles/Packaging/templates/postinst-frontend.template +++ b/BuildFiles/Packaging/templates/postinst-frontend.template @@ -2,4 +2,4 @@ #echo "Swarmops Frontend post-installation script running" #just make sure the upload folder exists -mkdir -p /opt/swarmops/upload +mkdir -p /var/lib/swarmops/upload diff --git a/Logic/Support/Document.cs b/Logic/Support/Document.cs index 9d621bb8..41147a00 100644 --- a/Logic/Support/Document.cs +++ b/Logic/Support/Document.cs @@ -145,11 +145,11 @@ namespace Swarmops.Logic.Support { if (Debugger.IsAttached) { - return @"C:\Windows\Temp\\Swarmops-Debug\\"; // Windows debugging environment + return @"C:\Windows\Temp\Swarmops-Debug\"; // Windows debugging environment } else { - return "/opt/swarmops/upload/"; // production location on Debian installation TODO: config file + return "/var/lib/swarmops/upload/"; // production location on Debian installation } } } diff --git a/Site5/Automation/UploadFileHandler.ashx b/Site5/Automation/UploadFileHandler.ashx index 35d1047e..e40af3d3 100644 --- a/Site5/Automation/UploadFileHandler.ashx +++ b/Site5/Automation/UploadFileHandler.ashx @@ -29,7 +29,7 @@ namespace Swarmops.Frontend.Automation } else { - return "/opt/swarmops/upload/"; // production location on Debian installation TODO: config file + return "/var/lib/swarmops/upload/"; // production location on Debian installation } } } diff --git a/Site5/Pages/v5/Ledgers/ResyncExternalAccount.aspx.cs b/Site5/Pages/v5/Ledgers/ResyncExternalAccount.aspx.cs index 289e3727..85e593fa 100644 --- a/Site5/Pages/v5/Ledgers/ResyncExternalAccount.aspx.cs +++ b/Site5/Pages/v5/Ledgers/ResyncExternalAccount.aspx.cs @@ -32,11 +32,11 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers { if (Debugger.IsAttached) { - return @"C:\Windows\Temp\\Swarmops-Debug\\"; // Windows debugging environment + return @"C:\Windows\Temp\Swarmops-Debug\"; // Windows debugging environment } else { - return "/opt/swarmops/upload/"; // production location on Debian installation TODO: config file + return "/var/lib/swarmops/upload/"; // production location on Debian installation TODO: config file } } } diff --git a/Site5/Pages/v5/Support/StreamUpload.aspx.cs b/Site5/Pages/v5/Support/StreamUpload.aspx.cs index 349666cb..5751eb56 100644 --- a/Site5/Pages/v5/Support/StreamUpload.aspx.cs +++ b/Site5/Pages/v5/Support/StreamUpload.aspx.cs @@ -28,11 +28,11 @@ namespace Swarmops.Pages.v5.Support { if (Debugger.IsAttached) { - return @"C:\Windows\Temp\\Swarmops-Debug\\"; // Windows debugging environment + return @"C:\Windows\Temp\Swarmops-Debug\"; // Windows debugging environment } else { - return "/opt/swarmops/upload/"; // production location on Debian installation TODO: config file + return "/var/lib/swarmops/upload/"; // production location on Debian installation TODO: config file } } } diff --git a/Utility/BotCode/BotLog.cs b/Utility/BotCode/BotLog.cs index 24955f29..54a05b85 100644 --- a/Utility/BotCode/BotLog.cs +++ b/Utility/BotCode/BotLog.cs @@ -32,7 +32,7 @@ namespace Swarmops.Utility.BotCode { DateTime now = DateTime.Now; - string logFileName = "logs" + System.IO.Path.DirectorySeparatorChar + "botlog-" + + string logFileName = "/var/log/swarmops/backend-log-" + now.ToString("yyyy-MM-dd-HH") + ".log"; using (StreamWriter writer = new StreamWriter(logFileName, true, Encoding.GetEncoding(1252)))