Commit b191638f by Torkel Ödegaard

feat(packaging): Make config file not part of package to simplify upgrade, made…

feat(packaging): Make config file not part of package to simplify upgrade, made commit always a short sha, changed RESTART_ON_UPGRADE to true by default, #7399, #7227
parent 2a09d4a5
...@@ -167,7 +167,6 @@ type linuxPackageOptions struct { ...@@ -167,7 +167,6 @@ type linuxPackageOptions struct {
serverBinPath string serverBinPath string
cliBinPath string cliBinPath string
configDir string configDir string
configFilePath string
ldapFilePath string ldapFilePath string
etcDefaultPath string etcDefaultPath string
etcDefaultFilePath string etcDefaultFilePath string
...@@ -188,8 +187,6 @@ func createDebPackages() { ...@@ -188,8 +187,6 @@ func createDebPackages() {
homeDir: "/usr/share/grafana", homeDir: "/usr/share/grafana",
binPath: "/usr/sbin", binPath: "/usr/sbin",
configDir: "/etc/grafana", configDir: "/etc/grafana",
configFilePath: "/etc/grafana/grafana.ini",
ldapFilePath: "/etc/grafana/ldap.toml",
etcDefaultPath: "/etc/default", etcDefaultPath: "/etc/default",
etcDefaultFilePath: "/etc/default/grafana-server", etcDefaultFilePath: "/etc/default/grafana-server",
initdScriptFilePath: "/etc/init.d/grafana-server", initdScriptFilePath: "/etc/init.d/grafana-server",
...@@ -210,8 +207,6 @@ func createRpmPackages() { ...@@ -210,8 +207,6 @@ func createRpmPackages() {
homeDir: "/usr/share/grafana", homeDir: "/usr/share/grafana",
binPath: "/usr/sbin", binPath: "/usr/sbin",
configDir: "/etc/grafana", configDir: "/etc/grafana",
configFilePath: "/etc/grafana/grafana.ini",
ldapFilePath: "/etc/grafana/ldap.toml",
etcDefaultPath: "/etc/sysconfig", etcDefaultPath: "/etc/sysconfig",
etcDefaultFilePath: "/etc/sysconfig/grafana-server", etcDefaultFilePath: "/etc/sysconfig/grafana-server",
initdScriptFilePath: "/etc/init.d/grafana-server", initdScriptFilePath: "/etc/init.d/grafana-server",
...@@ -256,10 +251,6 @@ func createPackage(options linuxPackageOptions) { ...@@ -256,10 +251,6 @@ func createPackage(options linuxPackageOptions) {
runPrint("cp", "-a", filepath.Join(workingDir, "tmp")+"/.", filepath.Join(packageRoot, options.homeDir)) runPrint("cp", "-a", filepath.Join(workingDir, "tmp")+"/.", filepath.Join(packageRoot, options.homeDir))
// remove bin path // remove bin path
runPrint("rm", "-rf", filepath.Join(packageRoot, options.homeDir, "bin")) runPrint("rm", "-rf", filepath.Join(packageRoot, options.homeDir, "bin"))
// copy sample ini file to /etc/grafana
runPrint("cp", "conf/sample.ini", filepath.Join(packageRoot, options.configFilePath))
// copy sample ldap toml config file to /etc/grafana/ldap.toml
runPrint("cp", "conf/ldap.toml", filepath.Join(packageRoot, options.ldapFilePath))
args := []string{ args := []string{
"-s", "dir", "-s", "dir",
...@@ -269,8 +260,6 @@ func createPackage(options linuxPackageOptions) { ...@@ -269,8 +260,6 @@ func createPackage(options linuxPackageOptions) {
"--url", "http://grafana.org", "--url", "http://grafana.org",
"--license", "\"Apache 2.0\"", "--license", "\"Apache 2.0\"",
"--maintainer", "contact@grafana.org", "--maintainer", "contact@grafana.org",
"--config-files", options.configFilePath,
"--config-files", options.ldapFilePath,
"--config-files", options.initdScriptFilePath, "--config-files", options.initdScriptFilePath,
"--config-files", options.etcDefaultFilePath, "--config-files", options.etcDefaultFilePath,
"--config-files", options.systemdServiceFilePath, "--config-files", options.systemdServiceFilePath,
...@@ -429,14 +418,10 @@ func setBuildEnv() { ...@@ -429,14 +418,10 @@ func setBuildEnv() {
} }
func getGitSha() string { func getGitSha() string {
v, err := runError("git", "describe", "--always", "--dirty") v, err := runError("git", "rev-parse", "--short", "HEAD")
if err != nil { if err != nil {
return "unknown-dev" return "unknown-dev"
} }
v = versionRe.ReplaceAllFunc(v, func(s []byte) []byte {
s[0] = '+'
return s
})
return string(v) return string(v)
} }
...@@ -517,14 +502,14 @@ func md5File(file string) error { ...@@ -517,14 +502,14 @@ func md5File(file string) error {
func sha1FilesInDist() { func sha1FilesInDist() {
filepath.Walk("./dist", func(path string, f os.FileInfo, err error) error { filepath.Walk("./dist", func(path string, f os.FileInfo, err error) error {
if path == "./dist" { if path == "./dist" {
return nil return nil
} }
if strings.Contains(path, ".sha1") == false { if strings.Contains(path, ".sha1") == false {
err := sha1File(path) err := sha1File(path)
if err != nil { if err != nil {
log.Printf("Failed to create sha file. error: %v\n", err) log.Printf("Failed to create sha file. error: %v\n", err)
} }
} }
return nil return nil
}) })
......
...@@ -42,6 +42,12 @@ case "$1" in ...@@ -42,6 +42,12 @@ case "$1" in
chown -R $GRAFANA_USER:$GRAFANA_GROUP /var/log/grafana /var/lib/grafana chown -R $GRAFANA_USER:$GRAFANA_GROUP /var/log/grafana /var/lib/grafana
chmod 755 /var/log/grafana /var/lib/grafana chmod 755 /var/log/grafana /var/lib/grafana
# copy user config files
if [ ! -f $CONF_FILE ]; then
cp /usr/share/grafana/conf/sample.ini $CONF_FILE
cp /usr/share/grafana/conf/ldap.toml /etc/grafana/ldap.toml
fi
# configuration files should not be modifiable by grafana user, as this can be a security issue # configuration files should not be modifiable by grafana user, as this can be a security issue
chown -Rh root:$GRAFANA_GROUP /etc/grafana/* chown -Rh root:$GRAFANA_GROUP /etc/grafana/*
chmod 755 /etc/grafana chmod 755 /etc/grafana
......
...@@ -14,6 +14,6 @@ CONF_DIR=/etc/grafana ...@@ -14,6 +14,6 @@ CONF_DIR=/etc/grafana
CONF_FILE=/etc/grafana/grafana.ini CONF_FILE=/etc/grafana/grafana.ini
RESTART_ON_UPGRADE=false RESTART_ON_UPGRADE=true
PLUGINS_DIR=/var/lib/grafana/plugins PLUGINS_DIR=/var/lib/grafana/plugins
...@@ -38,6 +38,12 @@ if [ $1 -eq 1 ] ; then ...@@ -38,6 +38,12 @@ if [ $1 -eq 1 ] ; then
-c "grafana user" grafana -c "grafana user" grafana
fi fi
# copy user config files
if [ ! -f $CONF_FILE ]; then
cp /usr/share/grafana/conf/sample.ini $CONF_FILE
cp /usr/share/grafana/conf/ldap.toml /etc/grafana/ldap.toml
fi
# Set user permissions on /var/log/grafana, /var/lib/grafana # Set user permissions on /var/log/grafana, /var/lib/grafana
mkdir -p /var/log/grafana /var/lib/grafana mkdir -p /var/log/grafana /var/lib/grafana
chown -R $GRAFANA_USER:$GRAFANA_GROUP /var/log/grafana /var/lib/grafana chown -R $GRAFANA_USER:$GRAFANA_GROUP /var/log/grafana /var/lib/grafana
......
...@@ -14,6 +14,6 @@ CONF_DIR=/etc/grafana ...@@ -14,6 +14,6 @@ CONF_DIR=/etc/grafana
CONF_FILE=/etc/grafana/grafana.ini CONF_FILE=/etc/grafana/grafana.ini
RESTART_ON_UPGRADE=false RESTART_ON_UPGRADE=true
PLUGINS_DIR=/var/lib/grafana/plugins PLUGINS_DIR=/var/lib/grafana/plugins
...@@ -59,7 +59,7 @@ module.exports = function(grunt) { ...@@ -59,7 +59,7 @@ module.exports = function(grunt) {
}); });
grunt.config('copy.backend_files', { grunt.config('copy.backend_files', {
expand: true, expand: true,
src: ['conf/defaults.ini', 'conf/sample.ini', 'vendor/phantomjs/*', 'scripts/*'], src: ['conf/*', 'vendor/phantomjs/*', 'scripts/*'],
options: { mode: true}, options: { mode: true},
dest: '<%= tempDir %>' dest: '<%= tempDir %>'
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment