Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
d32c03ed
Commit
d32c03ed
authored
Apr 10, 2015
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rpm working again, systemd working on centos 7
parent
3e496090
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
143 additions
and
73 deletions
+143
-73
build.go
+83
-34
packaging/deb/init.d/grafana-server
+1
-1
packaging/rpm/control/postinst
+11
-15
packaging/rpm/init.d/grafana-server
+14
-13
packaging/rpm/sysconfig/grafana-server
+11
-9
packaging/rpm/systemd/grafana-server.service
+21
-0
pkg/setting/setting.go
+2
-1
No files found.
build.go
View file @
d32c03ed
...
...
@@ -71,8 +71,7 @@ func main() {
case
"package"
:
//verifyGitRepoIsClean()
//grunt("release", "--pkgVer="+version)
createPackage
(
"deb"
,
"default"
)
//createPackage("rpm", "sysconfig")
createLinuxPackages
()
case
"latest"
:
makeLatestDistCopies
()
...
...
@@ -110,66 +109,116 @@ func readVersionFromPackageJson() {
version
=
jsonObj
[
"version"
]
.
(
string
)
}
func
createPackage
(
packageType
string
,
defaultPath
string
)
{
homeDir
:=
"/usr/share/grafana"
configDir
:=
"/etc/grafana"
configFilePath
:=
"/etc/grafana/grafana.ini"
defaultFilePath
:=
filepath
.
Join
(
"/etc/"
,
defaultPath
,
"grafana-server"
)
grafanaServerBinPath
:=
"/usr/sbin/"
+
serverBinaryName
initdScriptPath
:=
"/etc/init.d/grafana-server"
systemdServiceFilePath
:=
"/usr/lib/systemd/system/grafana-server.service"
type
linuxPackageOptions
struct
{
packageType
string
homeDir
string
binPath
string
configDir
string
configFilePath
string
etcDefaultPath
string
etcDefaultFilePath
string
initdScriptFilePath
string
systemdServiceFilePath
string
postinstSrc
string
initdScriptSrc
string
defaultFileSrc
string
systemdFileSrc
string
depends
[]
string
}
packageRoot
,
_
:=
ioutil
.
TempDir
(
""
,
"grafana-linux-pack"
)
packageConfDir
:=
filepath
.
Join
(
"packaging"
,
packageType
)
func
createLinuxPackages
()
{
createPackage
(
linuxPackageOptions
{
packageType
:
"deb"
,
homeDir
:
"/usr/share/grafana"
,
binPath
:
"/usr/sbin/grafana-server"
,
configDir
:
"/etc/grafana"
,
configFilePath
:
"/etc/grafana/grafana.ini"
,
etcDefaultPath
:
"/etc/default"
,
etcDefaultFilePath
:
"/etc/default/grafana-server"
,
initdScriptFilePath
:
"/etc/init.d/grafana-server"
,
systemdServiceFilePath
:
"/usr/lib/systemd/system/grafana-server.service"
,
postinstSrc
:
"packaging/deb/control/postinst"
,
initdScriptSrc
:
"packaging/deb/init.d/grafana-server"
,
defaultFileSrc
:
"packaging/deb/default/grafana-server"
,
systemdFileSrc
:
"packaging/deb/systemd/grafana-server.service"
,
depends
:
[]
string
{
"adduser"
,
"libfontconfig"
},
})
createPackage
(
linuxPackageOptions
{
packageType
:
"rpm"
,
homeDir
:
"/usr/share/grafana"
,
binPath
:
"/usr/sbin/grafana-server"
,
configDir
:
"/etc/grafana"
,
configFilePath
:
"/etc/grafana/grafana.ini"
,
etcDefaultPath
:
"/etc/sysconfig"
,
etcDefaultFilePath
:
"/etc/sysconfig/grafana-server"
,
initdScriptFilePath
:
"/etc/init.d/grafana-server"
,
systemdServiceFilePath
:
"/usr/lib/systemd/system/grafana-server.service"
,
postinstSrc
:
"packaging/rpm/control/postinst"
,
initdScriptSrc
:
"packaging/rpm/init.d/grafana-server"
,
defaultFileSrc
:
"packaging/rpm/sysconfig/grafana-server"
,
systemdFileSrc
:
"packaging/rpm/systemd/grafana-server.service"
,
depends
:
[]
string
{
"initscripts"
,
"fontconfig"
},
})
}
postintSrc
:=
filepath
.
Join
(
packageConfDir
,
"control/postinst"
)
initdScriptSrc
:=
filepath
.
Join
(
packageConfDir
,
"init.d/grafana-server"
)
defaultFileSrc
:=
filepath
.
Join
(
packageConfDir
,
defaultPath
,
"grafana-server"
)
systemdFileSrc
:=
filepath
.
Join
(
packageConfDir
,
"systemd/grafana-server.service"
)
func
createPackage
(
options
linuxPackageOptions
)
{
packageRoot
,
_
:=
ioutil
.
TempDir
(
""
,
"grafana-linux-pack"
)
// create directories
runPrint
(
"mkdir"
,
"-p"
,
filepath
.
Join
(
packageRoot
,
homeDir
))
runPrint
(
"mkdir"
,
"-p"
,
filepath
.
Join
(
packageRoot
,
configDir
))
runPrint
(
"mkdir"
,
"-p"
,
filepath
.
Join
(
packageRoot
,
options
.
homeDir
))
runPrint
(
"mkdir"
,
"-p"
,
filepath
.
Join
(
packageRoot
,
options
.
configDir
))
runPrint
(
"mkdir"
,
"-p"
,
filepath
.
Join
(
packageRoot
,
"/etc/init.d"
))
runPrint
(
"mkdir"
,
"-p"
,
filepath
.
Join
(
packageRoot
,
"/etc/"
,
d
efaultPath
))
runPrint
(
"mkdir"
,
"-p"
,
filepath
.
Join
(
packageRoot
,
options
.
etcD
efaultPath
))
runPrint
(
"mkdir"
,
"-p"
,
filepath
.
Join
(
packageRoot
,
"/usr/lib/systemd/system"
))
runPrint
(
"mkdir"
,
"-p"
,
filepath
.
Join
(
packageRoot
,
"/usr/sbin"
))
// copy binary
runPrint
(
"cp"
,
"-p"
,
filepath
.
Join
(
workingDir
,
"tmp/bin/"
+
serverBinaryName
),
filepath
.
Join
(
packageRoot
,
grafanaServerB
inPath
))
runPrint
(
"cp"
,
"-p"
,
filepath
.
Join
(
workingDir
,
"tmp/bin/"
+
serverBinaryName
),
filepath
.
Join
(
packageRoot
,
options
.
b
inPath
))
// copy init.d script
runPrint
(
"cp"
,
"-p"
,
initdScriptSrc
,
filepath
.
Join
(
packageRoot
,
initdScript
Path
))
runPrint
(
"cp"
,
"-p"
,
options
.
initdScriptSrc
,
filepath
.
Join
(
packageRoot
,
options
.
initdScriptFile
Path
))
// copy environment var file
runPrint
(
"cp"
,
"-p"
,
defaultFileSrc
,
filepath
.
Join
(
packageRoot
,
d
efaultFilePath
))
runPrint
(
"cp"
,
"-p"
,
options
.
defaultFileSrc
,
filepath
.
Join
(
packageRoot
,
options
.
etcD
efaultFilePath
))
// copy systemd file
runPrint
(
"cp"
,
"-p"
,
systemdFileSrc
,
filepath
.
Join
(
packageRoot
,
systemdServiceFilePath
))
runPrint
(
"cp"
,
"-p"
,
options
.
systemdFileSrc
,
filepath
.
Join
(
packageRoot
,
options
.
systemdServiceFilePath
))
// copy release files
runPrint
(
"cp"
,
"-a"
,
filepath
.
Join
(
workingDir
,
"tmp"
)
+
"/."
,
filepath
.
Join
(
packageRoot
,
homeDir
))
runPrint
(
"cp"
,
"-a"
,
filepath
.
Join
(
workingDir
,
"tmp"
)
+
"/."
,
filepath
.
Join
(
packageRoot
,
options
.
homeDir
))
// copy sample ini file to /etc/opt/grafana
runPrint
(
"cp"
,
"conf/sample.ini"
,
filepath
.
Join
(
packageRoot
,
configFilePath
))
runPrint
(
"cp"
,
"conf/sample.ini"
,
filepath
.
Join
(
packageRoot
,
options
.
configFilePath
))
args
:=
[]
string
{
"-s"
,
"dir"
,
"--description"
,
"Grafana"
,
"-C"
,
packageRoot
,
"--vendor"
,
"Grafana"
,
"--depends"
,
"adduser"
,
"--url"
,
"http://grafana.org"
,
"--license"
,
"Apache 2.0"
,
"--maintainer"
,
"contact@grafana.org"
,
"--config-files"
,
configFilePath
,
"--config-files"
,
initdScript
Path
,
"--config-files"
,
d
efaultFilePath
,
"--config-files"
,
systemdServiceFilePath
,
"--after-install"
,
postin
tSrc
,
"--config-files"
,
options
.
configFilePath
,
"--config-files"
,
options
.
initdScriptFile
Path
,
"--config-files"
,
options
.
etcD
efaultFilePath
,
"--config-files"
,
options
.
systemdServiceFilePath
,
"--after-install"
,
options
.
postins
tSrc
,
"--name"
,
"grafana"
,
"--version"
,
version
,
"-p"
,
"./dist"
,
"."
,
}
fmt
.
Println
(
"Creating package: "
,
packageType
)
runPrint
(
"fpm"
,
append
([]
string
{
"-t"
,
packageType
},
args
...
)
...
)
// add dependenciesj
for
_
,
dep
:=
range
options
.
depends
{
args
=
append
(
args
,
"--depends"
,
dep
)
}
args
=
append
(
args
,
"."
)
fmt
.
Println
(
"Creating package: "
,
options
.
packageType
)
runPrint
(
"fpm"
,
append
([]
string
{
"-t"
,
options
.
packageType
},
args
...
)
...
)
}
func
verifyGitRepoIsClean
()
{
...
...
packaging/deb/init.d/grafana-server
View file @
d32c03ed
...
...
@@ -70,7 +70,7 @@ case "$1" in
fi
# Prepare environment
mkdir
-p
"
$LOG_DIR
"
"
$DATA_DIR
"
"
$WORK_DIR
"
&&
chown
"
$GRAFANA_USER
"
:
"
$GRAFANA_GROUP
"
"
$LOG_DIR
"
"
$DATA_DIR
"
"
$WORK
_DIR
"
mkdir
-p
"
$LOG_DIR
"
"
$DATA_DIR
"
&&
chown
"
$GRAFANA_USER
"
:
"
$GRAFANA_GROUP
"
"
$LOG_DIR
"
"
$DATA
_DIR
"
touch
"
$PID_FILE
"
&&
chown
"
$GRAFANA_USER
"
:
"
$GRAFANA_GROUP
"
"
$PID_FILE
"
if
[
-n
"
$MAX_OPEN_FILES
"
]
;
then
...
...
packaging/rpm/control/postinst
View file @
d32c03ed
...
...
@@ -24,17 +24,17 @@ stopGrafana() {
fi
}
case
"
$1
"
in
configure
)
# Initial installation: $1 == 1
# Upgrade: $1 == 2, and configured to restart on upgrade
if
[
$1
-eq
1
]
;
then
[
-z
"
$GRAFANA_USER
"
]
&&
GRAFANA_USER
=
"grafana"
[
-z
"
$GRAFANA_GROUP
"
]
&&
GRAFANA_GROUP
=
"grafana"
if
!
getent group
"
$GRAFANA_GROUP
"
>
/dev/null 2>&1
;
then
addgroup
--system
"
$GRAFANA_GROUP
"
--quiet
groupadd
-r
"
$GRAFANA_GROUP
"
fi
if
!
id
$GRAFANA_USER
>
/dev/null 2>&1
;
then
adduser
--system
--home
/usr/share/grafana
--no-create-home
\
--ingroup
"
$GRAFANA_GROUP
"
--disabled-password
--shell
/bin/false
\
"
$GRAFANA_USER
"
if
!
getent passwd
"
$GRAFANA_USER
"
>
/dev/null 2>&1
;
then
useradd
-r
-g
grafana
-d
/usr/share/grafana
-s
/sbin/nologin
\
-c
"grafana user"
grafana
fi
# Set user permissions on /var/log/grafana, /var/lib/grafana
...
...
@@ -48,11 +48,6 @@ case "$1" in
find /etc/grafana
-type
f
-exec
chmod 644
{}
';'
find /etc/grafana
-type
d
-exec
chmod 755
{}
';'
# if $2 is set, this is an upgrade
if
(
[
-n
$2
]
&&
[
"
$RESTART_ON_UPGRADE
"
=
"true"
]
)
;
then
startGrafana
# this is a fresh installation
elif
[
-z
$2
]
;
then
if
[
-x
/bin/systemctl
]
;
then
echo
"### NOT starting on installation, please execute the following statements to configure elasticsearch to start automatically using systemd"
echo
" sudo /bin/systemctl daemon-reload"
...
...
@@ -66,6 +61,7 @@ case "$1" in
echo
"### In order to start grafana-server, execute"
echo
" sudo service grafana-server start"
fi
fi
;;
esac
elif
[
$1
-ge
2
-a
"
$RESTART_ON_UPGRADE
"
==
"true"
]
;
then
stopGrafana
startGrafana
fi
packaging/rpm/init.d/grafana-server
View file @
d32c03ed
...
...
@@ -20,9 +20,21 @@
# 3. Centos with initscripts package installed
PATH
=
/bin:/usr/bin:/sbin:/usr/sbin
NAME
=
grafana
NAME
=
grafana
-server
DESC
=
"Grafana Server"
GRAFANA_USER
=
grafana
GRAFANA_GROUP
=
grafana
GRAFANA_HOME
=
/usr/share/grafana
CONF_DIR
=
/etc/grafana
WORK_DIR
=
$GRAFANA_HOME
DATA_DIR
=
/var/lib/grafana
LOG_DIR
=
/var/log/grafana
CONF_FILE
=
$CONF_DIR
/grafana.ini
MAX_OPEN_FILES
=
10000
PID_FILE
=
/var/run/
$NAME
.pid
DAEMON
=
/usr/sbin/
$NAME
#
# init.d / servicectl compatibility (openSUSE)
#
...
...
@@ -38,21 +50,10 @@ if [ -f /etc/rc.d/init.d/functions ]; then
.
/etc/rc.d/init.d/functions
fi
GRAFANA_USER
=
grafana
GRAFANA_GROUP
=
grafana
GRAFANA_HOME
=
/opt/
$NAME
CONF_DIR
=
/etc/
$NAME
WORK_DIR
=
$GRAFANA_HOME
DATA_DIR
=
$GRAFANA_HOME
/data
LOG_DIR
=
/var/log/
$NAME
CONF_FILE
=
$CONF_DIR
/grafana.ini
MAX_OPEN_FILES
=
65535
# overwrite settings from default file
[
-e
/etc/sysconfig/
$NAME
]
&&
.
/etc/sysconfig/
$NAME
PID_FILE
=
/var/run/
$NAME
.pid
DAEMON
=
$GRAFANA_HOME
/bin/grafana
DAEMON_OPTS
=
"--pidfile=
${
PID_FILE
}
--config=
${
CONF_FILE
}
--default-data-path=
${
DATA_DIR
}
--default-log-path=
${
LOG_DIR
}
web"
# Check DAEMON exists
...
...
@@ -88,7 +89,7 @@ case "$1" in
fi
# Prepare environment
mkdir
-p
"
$LOG_DIR
"
"
$DATA_DIR
"
"
$WORK_DIR
"
&&
chown
"
$GRAFANA_USER
"
:
"
$GRAFANA_GROUP
"
"
$LOG_DIR
"
"
$DATA_DIR
"
"
$WORK
_DIR
"
mkdir
-p
"
$LOG_DIR
"
"
$DATA_DIR
"
&&
chown
"
$GRAFANA_USER
"
:
"
$GRAFANA_GROUP
"
"
$LOG_DIR
"
"
$DATA
_DIR
"
touch
"
$PID_FILE
"
&&
chown
"
$GRAFANA_USER
"
:
"
$GRAFANA_GROUP
"
"
$PID_FILE
"
if
[
-n
"
$MAX_OPEN_FILES
"
]
;
then
...
...
packaging/rpm/sysconfig/grafana-server
View file @
d32c03ed
GRAFANA_USER=grafana
#GRAFANA_USER
=grafana
GRAFANA_GROUP
=grafana
#GRAFANA_GROUP=
grafana
GRAFANA_HOME=/usr/share/
grafana
#
LOG_DIR=/var/log/grafana
LOG_DIR=/var/log/grafana
#GRAFANA_HOME=/opt/grafana
#DATA_DIR=/opt/data/grafana
#WORK_DIR=/opt/grafana
DATA_DIR=/var/lib/grafana
#CONF_DIR=/etc/grafana
#CONF_FILE=/etc/grafana/grafana.ini
MAX_OPEN_FILES=10000
#RESTART_ON_UPGRADE=true
CONF_DIR=/etc/grafana
CONF_FILE=/etc/grafana/grafana.ini
RESTART_ON_UPGRADE=true
packaging/rpm/systemd/grafana-server.service
0 → 100644
View file @
d32c03ed
[Unit]
Description=Starts and stops a single grafana instance on this system
Documentation=http://docs.grafana.org
Wants=network-online.target
After=network-online.target
[Service]
EnvironmentFile=/etc/sysconfig/grafana-server
User=grafana
Group=grafana
Type=simple
WorkingDirectory=/usr/share/grafana
ExecStart=/usr/sbin/grafana-server \
--config=${CONF_FILE} \
cfg:default.paths.logs=${LOG_DIR} \
cfg:default.paths.data=${DATA_DIR} \
LimitNOFILE=10000
TimeoutStopSec=20
[Install]
WantedBy=multi-user.target
pkg/setting/setting.go
View file @
d32c03ed
...
...
@@ -227,6 +227,7 @@ func evalConfigValues() {
func
loadSpecifedConfigFile
(
configFile
string
)
{
userConfig
,
err
:=
ini
.
Load
(
configFile
)
userConfig
.
BlockMode
=
false
if
err
!=
nil
{
log
.
Fatal
(
3
,
"Failed to parse %v, %v"
,
configFile
,
err
)
}
...
...
@@ -262,7 +263,7 @@ func loadConfiguration(args *CommandLineArgs) {
configFiles
=
append
(
configFiles
,
defaultConfigFile
)
Cfg
,
err
=
ini
.
Load
(
defaultConfigFile
)
Cfg
.
BlockMode
=
tru
e
Cfg
.
BlockMode
=
fals
e
if
err
!=
nil
{
log
.
Fatal
(
3
,
"Failed to parse defaults.ini, %v"
,
err
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment