diff --git a/build.go b/build.go index 7943bd8716c..72f7f498d97 100644 --- a/build.go +++ b/build.go @@ -14,13 +14,13 @@ import ( "log" "os" "os/exec" + "path" "path/filepath" "regexp" "runtime" "strconv" "strings" "time" - "path" ) var ( @@ -126,9 +126,9 @@ func makeLatestDistCopies() { log.Fatalf("failed to create latest copies. Cannot read from /dist") } - latestMapping := map[string]string { - ".deb": "dist/grafana_latest_amd64.deb", - ".rpm": "dist/grafana-latest-1.x86_64.rpm", + latestMapping := map[string]string{ + ".deb": "dist/grafana_latest_amd64.deb", + ".rpm": "dist/grafana-latest-1.x86_64.rpm", ".tar.gz": "dist/grafana-latest.linux-x64.tar.gz", } @@ -287,6 +287,14 @@ func createPackage(options linuxPackageOptions) { "-p", "./dist", } + if options.packageType == "rpm" { + args = append(args, "--rpm-posttrans", "packaging/rpm/control/posttrans") + } + + if options.packageType == "deb" { + args = append(args, "--deb-no-default-config-files") + } + if pkgArch != "" { args = append(args, "-a", pkgArch) } diff --git a/packaging/rpm/control/postinst b/packaging/rpm/control/postinst old mode 100644 new mode 100755 index be3d7692a5f..cf31112679d --- a/packaging/rpm/control/postinst +++ b/packaging/rpm/control/postinst @@ -68,13 +68,6 @@ if [ $1 -eq 1 ] ; then echo " sudo service grafana-server start" fi elif [ $1 -ge 2 ] ; then - if [ -x /opt/grafana/ ]; then - echo "### Upgrading Notice ### " - echo "-- New grafana install home is /usr/share/grafana" - echo "-- Please move sqlite3 database to /var/lib/grafana/" - echo "-- Notice: service name && binary changed to grafana-server" - fi - if [ "$RESTART_ON_UPGRADE" == "true" ]; then stopGrafana startGrafana diff --git a/packaging/rpm/control/posttrans b/packaging/rpm/control/posttrans new file mode 100755 index 00000000000..0afe4561a93 --- /dev/null +++ b/packaging/rpm/control/posttrans @@ -0,0 +1,32 @@ +#!/bin/sh + +set -e + +echo "POSTTRANS: Running script" + +[ -f /etc/sysconfig/grafana-server ] && . /etc/sysconfig/grafana-server + +# copy config files if missing +if [ ! -f /etc/grafana/grafana.ini ]; then + echo "POSTTRANS: Config file not found" + + if [ -f /etc/grafana/grafana.ini.rpmsave ]; then + echo "POSTTRANS: /etc/grafana/grafana.ini.rpmsave config file found." + mv /etc/grafana/grafana.ini.rpmsave /etc/grafana/grafana.ini + echo "POSTTRANS: /etc/grafana/grafana.ini restored" + + if [ -f /etc/grafana/ldap.toml.rpmsave ]; then + echo "POSTTRANS: /etc/grafana/ldap.toml.rpmsave found" + mv /etc/grafana/ldap.toml.rpmsave /etc/grafana/ldap.toml + echo "POSTTRANS: /etc/grafana/ldap.toml restored" + fi + + echo "POSTTRANS: Restoring config file permissions" + chown -Rh root:$GRAFANA_GROUP /etc/grafana/* + chmod 755 /etc/grafana + find /etc/grafana -type f -exec chmod 640 {} ';' + find /etc/grafana -type d -exec chmod 755 {} ';' + fi +fi + +