summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorJanne Heß2016-10-06 19:16:33 +0200
committerJanne Heß2016-10-06 19:35:15 +0200
commit94d7a50433d26d0127ee262a28ede3287e050afe (patch)
treee282057fd29d21320f6abde2ae5d040e3f457b00
downloadaur-94d7a50433d26d0127ee262a28ede3287e050afe.tar.gz
Initial commit of the asciinema server
-rw-r--r--.SRCINFO42
-rw-r--r--PKGBUILD109
-rw-r--r--asciinema-server-git.install33
-rw-r--r--asciinema-sidekiq.service32
-rw-r--r--asciinema-unicorn.service32
-rw-r--r--asciinema.conf2
-rw-r--r--asciinema.logrotate10
-rw-r--r--asciinema.yml30
-rw-r--r--database.yml8
9 files changed, 298 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO
new file mode 100644
index 000000000000..07fec0eb9c41
--- /dev/null
+++ b/.SRCINFO
@@ -0,0 +1,42 @@
+# Generated by mksrcinfo v8
+# Thu Oct 6 17:35:01 UTC 2016
+pkgbase = asciinema-server-git
+ pkgdesc = asciinema.org web app
+ pkgver = 0.0.0
+ pkgrel = 1
+ url = https://asciinema.org/
+ install = asciinema-server-git.install
+ arch = i386
+ arch = x86_64
+ license = AGPL3
+ depends = ruby
+ depends = ruby-bundler
+ depends = phantomjs
+ depends = postgresql-libs
+ depends = libtsm-asciinema
+ depends = redis
+ depends = smtp-server
+ optdepends = postgresql: database backend
+ provides = asciinema-server
+ conflicts = asciinema-server
+ backup = etc/webapps/asciinema/database.yml
+ backup = etc/webapps/asciinema/asciinema.yml
+ backup = etc/logrotate.d/asciinema
+ backup = etc/conf.d/asciinema
+ source = git://github.com/asciinema/asciinema.org
+ source = asciinema.logrotate
+ source = asciinema-unicorn.service
+ source = asciinema-sidekiq.service
+ source = asciinema.conf
+ source = database.yml
+ source = asciinema.yml
+ sha512sums = SKIP
+ sha512sums = feac61a6458072fdef9e19b5e636484e31e6cc77daefd650403852f48bf0773d7ca7eb0af343066c2d733af1c32e164043bc78cf1a2dfb4ec271d4488a53b3da
+ sha512sums = 0b3be0a6326741f82924160d39002a8780f8f90521e8203fe595cc6b8243867eec6a00319d00fa62a46c99de12beb38c14ceae1e4ffa4f86a55d063e63250847
+ sha512sums = 801313fda2eab446fa569e11e33f0ab9b84f2fe0678bbf0b74e19eea1250eb7457ed7cf3163fc10b713767962283896b8360df9964013f644012d1c8705a4b81
+ sha512sums = 804add7ea903c746309577450ea6fe3eaecab57a9beb79be1953dee34ce0957daac43fa7a053be7daf1ab32178944dcb9a861b4d6da494f0d559d9f265b88446
+ sha512sums = 70c547f62829707f8f7340c10b6e83fb91874cd8fa535b8a318b4fc3019f3deddb820a6522278a41bc09f28295a0427b4361bbb726260afe4626bf1a8582da69
+ sha512sums = b3f6225faabb2632e961489e399204392d532d197517de41b16e633257040ec0f0aa49434ffba672943cf65670041a94c8aec876ca93ba95b0dbfbc55225b314
+
+pkgname = asciinema-server-git
+
diff --git a/PKGBUILD b/PKGBUILD
new file mode 100644
index 000000000000..cff4bc0d1656
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,109 @@
+# Maintainer: Janne Heß <jannehess@gmail.com>
+
+pkgname=asciinema-server-git
+pkgver=0.0.0
+pkgrel=1
+pkgdesc='asciinema.org web app'
+arch=('i386' 'x86_64')
+url='https://asciinema.org/'
+license=('AGPL3')
+depends=('ruby' 'ruby-bundler' 'phantomjs' 'postgresql-libs' 'libtsm-asciinema' 'redis' 'smtp-server')
+makepdepends=('libxslt' 'nodejs')
+optdepends=('postgresql: database backend')
+provides=('asciinema-server')
+conflicts=('asciinema-server')
+backup=('etc/webapps/asciinema/database.yml'
+ 'etc/webapps/asciinema/asciinema.yml'
+ 'etc/logrotate.d/asciinema'
+ 'etc/conf.d/asciinema')
+install="${pkgname}.install"
+source=('git://github.com/asciinema/asciinema.org'
+ 'asciinema.logrotate'
+ 'asciinema-unicorn.service'
+ 'asciinema-sidekiq.service'
+ 'asciinema.conf'
+ 'database.yml'
+ 'asciinema.yml')
+sha512sums=('SKIP'
+ 'feac61a6458072fdef9e19b5e636484e31e6cc77daefd650403852f48bf0773d7ca7eb0af343066c2d733af1c32e164043bc78cf1a2dfb4ec271d4488a53b3da'
+ '0b3be0a6326741f82924160d39002a8780f8f90521e8203fe595cc6b8243867eec6a00319d00fa62a46c99de12beb38c14ceae1e4ffa4f86a55d063e63250847'
+ '801313fda2eab446fa569e11e33f0ab9b84f2fe0678bbf0b74e19eea1250eb7457ed7cf3163fc10b713767962283896b8360df9964013f644012d1c8705a4b81'
+ '804add7ea903c746309577450ea6fe3eaecab57a9beb79be1953dee34ce0957daac43fa7a053be7daf1ab32178944dcb9a861b4d6da494f0d559d9f265b88446'
+ '70c547f62829707f8f7340c10b6e83fb91874cd8fa535b8a318b4fc3019f3deddb820a6522278a41bc09f28295a0427b4361bbb726260afe4626bf1a8582da69'
+ 'b3f6225faabb2632e961489e399204392d532d197517de41b16e633257040ec0f0aa49434ffba672943cf65670041a94c8aec876ca93ba95b0dbfbc55225b314')
+
+_srcdir='asciinema.org'
+_datadir='/usr/share/webapps/asciinema'
+_etcdir='/etc/webapps/asciinema'
+
+prepare() {
+ cd "${srcdir}/${_srcdir}"
+
+ # Patch gem versions as arch has a pretty new ruby
+ sed -i \
+ -e 's/eventmachine (1.0.3)/eventmachine (1.2.0)/g' \
+ -e 's/kgio .*$/kgio (2.10.0)/g' \
+ -e 's/raindrops .*$/raindrops (0.17.0)/g' \
+ Gemfile.lock
+
+ # Configure sidekiq
+ echo ':pidfile: /run/asciinema/sidekiq.pid' >> config/sidekiq.yml
+ echo ':logfile: /var/log/asciinema/sidekiq_production.log' >> config/sidekiq.yml
+}
+
+build() {
+ cd "${srcdir}/${_srcdir}"
+
+ msg "Fetching bundled gems..."
+ bundle install -j$(nproc) --no-cache --deployment --without development test
+
+ msg "Precompiling assets..."
+ # We'll temporarily stick this in here so we can build the assets
+ cp config/database.yml.example config/database.yml
+ bundle exec rake assets:precompile RAILS_ENV=production
+ # After building assets, clean this up again
+ rm config/database.yml
+
+ # Build terminal executable
+ cd src
+ make all
+ cd ..
+}
+
+package() {
+ cd "${srcdir}/${_srcdir}"
+
+ install -d "${pkgdir}/usr/share/webapps"
+
+ # Main installation
+ cp -r "${srcdir}/${_srcdir}" "${pkgdir}/${_datadir}"
+ chmod 755 "${pkgdir}/${_datadir}"
+ rm -r "${pkgdir}/${_datadir}/tmp"
+ ln -s "/run/asciinema/tmp" "${pkgdir}/${_datadir}/tmp"
+
+ # Uploads directory
+ install -dm600 "${pkgdir}/var/lib/asciinema/uploads"
+ rm -r "${pkgdir}/${_datadir}/uploads"
+ ln -s /var/lib/asciinema/uploads "${pkgdir}/${_datadir}/uploads"
+
+ # Config
+ install -dm755 "${pkgdir}${_etcdir}"
+ install -Dm644 "${srcdir}/database.yml" "${pkgdir}/${_etcdir}/database.yml"
+ install -Dm644 "${srcdir}/asciinema.yml" "${pkgdir}/${_etcdir}/asciinema.yml"
+ ln -s "${_etcdir}/database.yml" "${pkgdir}/${_datadir}/config/database.yml"
+ ln -s "${_etcdir}/asciinema.yml" "${pkgdir}/${_datadir}/config/asciinema.yml"
+
+ # Log
+ mkdir -p "${pkgdir}/var/log/asciinema"
+ rm -r "${pkgdir}/${_datadir}/log"
+ ln -s '/var/log/asciinema' "${pkgdir}/${_datadir}/log"
+ install -Dm644 "${srcdir}/asciinema.logrotate" "${pkgdir}/etc/logrotate.d/asciinema"
+
+ # systemd services
+ for unit in unicorn sidekiq; do
+ install -Dm644 "${srcdir}/asciinema-${unit}.service" "${pkgdir}/usr/lib/systemd/system/asciinema-${unit}.service"
+ done
+
+ # conf.d
+ install -Dm644 "${srcdir}/asciinema.conf" "${pkgdir}/etc/conf.d/asciinema"
+}
diff --git a/asciinema-server-git.install b/asciinema-server-git.install
new file mode 100644
index 000000000000..678116d46016
--- /dev/null
+++ b/asciinema-server-git.install
@@ -0,0 +1,33 @@
+ownstuff() {
+ getent group asciinema &>/dev/null || groupadd -r asciinema
+ getent passwd asciinema &>/dev/null || useradd -Mrg asciinema -d /usr/share/webapps/asciinema -s /bin/nologin -c 'Asciinema Server user' asciinema
+
+ chown -R asciinema:asciinema /var/lib/asciinema /var/log/asciinema
+}
+
+post_install() {
+ ownstuff
+
+ echo "Asciinema will listen on 127.0.0.1:8085"
+ echo "To change this, edit /etc/conf.d/asciinema."
+ echo
+ echo "Before starting Asciinema, you need to configure it and initialize the database."
+ echo "The configuration files are found in /etc/webapps/asciinema."
+ echo "To initialize the database, run:"
+ echo "# su - asciinema -s /bin/sh -c \"cd '/usr/share/webapps/asciinema'; bundle exec rake db:setup RAILS_ENV=production\""
+}
+
+post_upgrade() {
+ ownstuff
+
+ echo "You should upgrade your database:"
+ echo "# su - asciinema -s /bin/sh -c \"cd '/usr/share/webapps/asciinema'; bundle exec rake db:migrate RAILS_ENV=production\""
+ echo "Afterwards, restart Asciinema:"
+ echo "# systemctl daemon-reload"
+ echo "# systemctl restart asciinema-sidekiq asciinema-unicorn"
+}
+
+post_remove() {
+ getent passwd asciinema &>/dev/null && userdel asciinema || true
+ getent group asciinema &>/dev/null && (groupdel asciinema || true) || true
+}
diff --git a/asciinema-sidekiq.service b/asciinema-sidekiq.service
new file mode 100644
index 000000000000..cbeb775f5d9a
--- /dev/null
+++ b/asciinema-sidekiq.service
@@ -0,0 +1,32 @@
+[Unit]
+Description=Asciinema Sidekiq Server
+Requires=redis.service asciinema-unicorn.service
+Wants=postgresql.service
+After=redis.service postgresql.service asciinema-unicorn.service
+JounsNamespaceOf=asciinema-unicorn.service
+
+[Service]
+ExecStart=/usr/bin/bundle exec sidekiq -e production $SIDEKIQ_OPTS
+ExecStop=/usr/bin/bundle exec sidekiqctl stop /run/asciinema/sidekiq.pid
+
+WorkingDirectory=/usr/share/webapps/asciinema
+Evironment=RAILS_ENV=production
+EnvironmentFile=-/etc/conf.d/asciinema
+
+Restart=on-failur
+RestartSec=3
+PIDFile=/run/asciinema/sidekiq.pid
+
+User=asciinema
+Group=asciinema
+
+CapabilityBoundingSet=
+ProtectDevices=true
+ProtectSystem=full
+ProtectHome=true
+
+RuntimeDirectory=asciinema
+RuntimeDirectoryMode=755
+
+[Install]
+WantedBy=multi-user.target
diff --git a/asciinema-unicorn.service b/asciinema-unicorn.service
new file mode 100644
index 000000000000..30f376f923e4
--- /dev/null
+++ b/asciinema-unicorn.service
@@ -0,0 +1,32 @@
+[Unit]
+Description=Asciinema Unicorn Server
+Requires=redis.service
+Wants=postgresql.service
+After=redis.ervice postgresql.service network.target
+
+[Service]
+ExecStartPre=/usr/bin/mkdir -p /run/asciinema/tmp
+ExecStart=/usr/bin/bundle exec rails server --pid=/run/asciinema/unicorn.pid $UNICORN_OPTS
+
+WorkingDirectory=/usr/share/webapps/asciinema
+Environment=RAILS_ENV=production
+EnvironmentFile=-/etc/conf.d/asciinema
+
+Restart=on-failure
+RestartSec=3
+PIDFile=/run/asciinema/unicorn.pid
+
+User=asciinema
+Group=asciinema
+
+CapabilityBoundingSet=
+NoNewPrivileges=true
+ProtectDevices=true
+ProtectSystem=full
+PrivateTmp=true
+
+RuntimeDirectory=asciinema
+RuntimeDirectoryMode=755
+
+[Install]
+WantedBy=multi-user.target
diff --git a/asciinema.conf b/asciinema.conf
new file mode 100644
index 000000000000..4001d1b29292
--- /dev/null
+++ b/asciinema.conf
@@ -0,0 +1,2 @@
+UNICORN_OPTS="--binding=127.0.0.1 --port=8085"
+SIDEKIQ_OPTS=""
diff --git a/asciinema.logrotate b/asciinema.logrotate
new file mode 100644
index 000000000000..9234435cd82f
--- /dev/null
+++ b/asciinema.logrotate
@@ -0,0 +1,10 @@
+# Logrotate settings for the Asciinema Server
+
+/var/log/asciinema/*.log {
+ daily
+ missingok
+ rotate 20
+ compress
+ notifyempty
+ copytruncate
+}
diff --git a/asciinema.yml b/asciinema.yml
new file mode 100644
index 000000000000..496a4bde4d15
--- /dev/null
+++ b/asciinema.yml
@@ -0,0 +1,30 @@
+---
+# Integration
+#:add_this_profile_id: ""
+#:bugsnag_api_key: ""
+#:google_analytics_id: ""
+#:home_asciicast_id: 0
+
+# Security
+:secret_token: "CHANGE THIS TO SOMETHING SECRET"
+:admin_ids: [ ]
+
+# Mail
+:from_email: "My Asciinema <asciinema@example.com>"
+:scheme: "http"
+:host: "localhost:8085"
+#smtp_settings:
+# :address: "localhost"
+# :port: 25
+# :user_name: "asciinema"
+# :password: "asciinema"
+# :authentication: "plain"
+# :enable_starttls_auto: false
+
+# Storage
+#:aws_access_key_id: ""
+#:aws_bucket: ""
+#:aws_region: ""
+#:aws_secret_access_key: ""
+#:carrierwave_storage: "file"
+#:carrierwave_storage_dir_prefix: "./uploads"
diff --git a/database.yml b/database.yml
new file mode 100644
index 000000000000..4f1b45c7e281
--- /dev/null
+++ b/database.yml
@@ -0,0 +1,8 @@
+production:
+ adapter: postgresql
+ encoding: unicode
+ pool: 25
+ host: localhost
+ database: asciinema
+ username: asciinema
+ password: asciinema