Skip to content
This repository has been archived by the owner on May 2, 2023. It is now read-only.

Commit

Permalink
Switch to /opt on Arch, run bundle during build
Browse files Browse the repository at this point in the history
  • Loading branch information
evs-ch committed Mar 31, 2018
1 parent 810f89c commit c2a6ad1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 19 deletions.
27 changes: 17 additions & 10 deletions PKGBUILD/PKGBUILD
@@ -1,6 +1,6 @@
pkgname='envizon-git'
_pkgname='envizon'
pkgver=37.24d86d4
pkgver=38.810f89c
pkgrel=1
pkgdesc='network visualization tool with focus on red / blue team requirements'
url='https://evait-security.github.io/envizon/'
Expand All @@ -24,26 +24,33 @@ pkgver() {
echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

package() {
cd "$srcdir"
build() {
cd "$srcdir/${_pkgname}"
bundle config --local build.nokogiri --use-system-libraries
bundle install --path vendor/bundle --without development test -j"$(nproc)" --no-cache
mkdir -p .ssl
}

package() {
mkdir -p "$pkgdir/usr/lib/sysusers.d/" \
"$pkgdir/usr/bin" \
"$pkgdir/usr/share"
"$pkgdir/opt"

install -m644 "${_pkgname}.sysusers.conf"\
"$pkgdir/usr/lib/sysusers.d/${_pkgname}.conf"

cp -ar "${_pkgname}" "$pkgdir/usr/share/${_pkgname}"
cp db_setup.sh "$pkgdir/usr/share/${_pkgname}/"
chmod +x "$pkgdir/usr/share/${_pkgname}/"
cp -ar "${_pkgname}" "$pkgdir/opt/${_pkgname}"
cp db_setup.sh "$pkgdir/opt/${_pkgname}/"
chmod +x "$pkgdir/opt/${_pkgname}/"

rm -rf "$pkgdir/opt/${_pkgname}/docker"
rm -rf "$pkgdir/opt/${_pkgname}/.github"

rm -rf "$pkgdir/usr/share/${_pkgname}/docker"
rm -rf "$pkgdir/usr/share/${_pkgname}/.github"
chmod -R g+w "$pkgdir/opt/${_pkgname}"

cat > "$pkgdir/usr/bin/${_pkgname}" << EOF
#!/bin/sh
cd /usr/share/${_pkgname}
cd /opt/${_pkgname}
export SECRET_KEY_BASE=\$(cat config/secret)
RAILS_ENV=production
export RAILS_ENV
Expand Down
20 changes: 11 additions & 9 deletions PKGBUILD/envizon.install
@@ -1,8 +1,5 @@
post_install() {
cd /usr/share/envizon || exit
bundle config --local build.nokogiri --use-system-libraries
bundle install --path vendor/bundle --without development test
mkdir -p .ssl
cd /opt/envizon || exit
openssl req -new -newkey rsa:2048 -days 365 -nodes -x509 \
-subj "/C=DE/ST=None/L=None/O=evait/CN=None" \
-keyout .ssl/localhost.key -out .ssl/localhost.crt
Expand All @@ -13,18 +10,23 @@ post_install() {
}

post_upgrade() {
if [ -d /usr/share/envizon ]; then
echo ">> Found directory '/usr/share/envizon'. This might be left over"
echo ">> from a previous installation. You should check if you still need it,"
echo ">> otherwise it can probably be removed."
fi
post_group "$@"
post_common "$@"
}

post_remove() {
rm -r /usr/share/envizon
rm -r /opt/envizon
}

post_group() {
chown -R :envizon /usr/share/envizon
chmod -R g+w /usr/share/envizon
chmod -R g+r /usr/share/envizon/.ssl
chown -R :envizon /opt/envizon
chmod -R g+w /opt/envizon
chmod -R g+r /opt/envizon/.ssl
}

post_common() {
Expand All @@ -35,5 +37,5 @@ post_common() {
echo '>> with '\''exec sg envizon newgrp `id -gn`'\''.'
echo ">>"
echo ">> A running and initialized PostgreSQL instance is required. If you haven't done so yet,"
echo ">> run sudo -u postgres /usr/share/envizon/db_setup.sh to create a database and the database user."
echo ">> run sudo -u postgres /opt/envizon/db_setup.sh to create a database and the database user."
}

0 comments on commit c2a6ad1

Please sign in to comment.