mirror of
https://github.com/grafana/grafana.git
synced 2024-12-28 01:41:24 -06:00
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
This commit is contained in:
parent
2a09d4a5a6
commit
b191638f41
29
build.go
29
build.go
@ -167,7 +167,6 @@ type linuxPackageOptions struct {
|
||||
serverBinPath string
|
||||
cliBinPath string
|
||||
configDir string
|
||||
configFilePath string
|
||||
ldapFilePath string
|
||||
etcDefaultPath string
|
||||
etcDefaultFilePath string
|
||||
@ -188,8 +187,6 @@ func createDebPackages() {
|
||||
homeDir: "/usr/share/grafana",
|
||||
binPath: "/usr/sbin",
|
||||
configDir: "/etc/grafana",
|
||||
configFilePath: "/etc/grafana/grafana.ini",
|
||||
ldapFilePath: "/etc/grafana/ldap.toml",
|
||||
etcDefaultPath: "/etc/default",
|
||||
etcDefaultFilePath: "/etc/default/grafana-server",
|
||||
initdScriptFilePath: "/etc/init.d/grafana-server",
|
||||
@ -210,8 +207,6 @@ func createRpmPackages() {
|
||||
homeDir: "/usr/share/grafana",
|
||||
binPath: "/usr/sbin",
|
||||
configDir: "/etc/grafana",
|
||||
configFilePath: "/etc/grafana/grafana.ini",
|
||||
ldapFilePath: "/etc/grafana/ldap.toml",
|
||||
etcDefaultPath: "/etc/sysconfig",
|
||||
etcDefaultFilePath: "/etc/sysconfig/grafana-server",
|
||||
initdScriptFilePath: "/etc/init.d/grafana-server",
|
||||
@ -256,10 +251,6 @@ func createPackage(options linuxPackageOptions) {
|
||||
runPrint("cp", "-a", filepath.Join(workingDir, "tmp")+"/.", filepath.Join(packageRoot, options.homeDir))
|
||||
// remove bin path
|
||||
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{
|
||||
"-s", "dir",
|
||||
@ -269,8 +260,6 @@ func createPackage(options linuxPackageOptions) {
|
||||
"--url", "http://grafana.org",
|
||||
"--license", "\"Apache 2.0\"",
|
||||
"--maintainer", "contact@grafana.org",
|
||||
"--config-files", options.configFilePath,
|
||||
"--config-files", options.ldapFilePath,
|
||||
"--config-files", options.initdScriptFilePath,
|
||||
"--config-files", options.etcDefaultFilePath,
|
||||
"--config-files", options.systemdServiceFilePath,
|
||||
@ -429,14 +418,10 @@ func setBuildEnv() {
|
||||
}
|
||||
|
||||
func getGitSha() string {
|
||||
v, err := runError("git", "describe", "--always", "--dirty")
|
||||
v, err := runError("git", "rev-parse", "--short", "HEAD")
|
||||
if err != nil {
|
||||
return "unknown-dev"
|
||||
}
|
||||
v = versionRe.ReplaceAllFunc(v, func(s []byte) []byte {
|
||||
s[0] = '+'
|
||||
return s
|
||||
})
|
||||
return string(v)
|
||||
}
|
||||
|
||||
@ -517,14 +502,14 @@ func md5File(file string) error {
|
||||
func sha1FilesInDist() {
|
||||
filepath.Walk("./dist", func(path string, f os.FileInfo, err error) error {
|
||||
if path == "./dist" {
|
||||
return nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
if strings.Contains(path, ".sha1") == false {
|
||||
if strings.Contains(path, ".sha1") == false {
|
||||
err := sha1File(path)
|
||||
if err != nil {
|
||||
log.Printf("Failed to create sha file. error: %v\n", err)
|
||||
}
|
||||
if err != nil {
|
||||
log.Printf("Failed to create sha file. error: %v\n", err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
@ -42,6 +42,12 @@ case "$1" in
|
||||
chown -R $GRAFANA_USER:$GRAFANA_GROUP /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
|
||||
chown -Rh root:$GRAFANA_GROUP /etc/grafana/*
|
||||
chmod 755 /etc/grafana
|
||||
|
@ -14,6 +14,6 @@ CONF_DIR=/etc/grafana
|
||||
|
||||
CONF_FILE=/etc/grafana/grafana.ini
|
||||
|
||||
RESTART_ON_UPGRADE=false
|
||||
RESTART_ON_UPGRADE=true
|
||||
|
||||
PLUGINS_DIR=/var/lib/grafana/plugins
|
||||
|
@ -38,6 +38,12 @@ if [ $1 -eq 1 ] ; then
|
||||
-c "grafana user" grafana
|
||||
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
|
||||
mkdir -p /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
|
||||
|
||||
CONF_FILE=/etc/grafana/grafana.ini
|
||||
|
||||
RESTART_ON_UPGRADE=false
|
||||
RESTART_ON_UPGRADE=true
|
||||
|
||||
PLUGINS_DIR=/var/lib/grafana/plugins
|
||||
|
@ -59,7 +59,7 @@ module.exports = function(grunt) {
|
||||
});
|
||||
grunt.config('copy.backend_files', {
|
||||
expand: true,
|
||||
src: ['conf/defaults.ini', 'conf/sample.ini', 'vendor/phantomjs/*', 'scripts/*'],
|
||||
src: ['conf/*', 'vendor/phantomjs/*', 'scripts/*'],
|
||||
options: { mode: true},
|
||||
dest: '<%= tempDir %>'
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user