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
ad2065af
Commit
ad2065af
authored
Mar 02, 2015
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Began work on deb and rpm packaging, #1476
parent
9710771f
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
232 additions
and
31 deletions
+232
-31
build.go
+102
-18
docker/debtest/Dockerfile
+4
-0
docker/debtest/build.sh
+10
-0
pkg/util/encoding_test.go
+1
-1
scripts/init.sh
+108
-0
src/app/plugins/datasource/influxdb_08/partials/config.html
+6
-11
tasks/build_task.js
+1
-1
No files found.
build.go
View file @
ad2065af
...
...
@@ -8,10 +8,10 @@ import (
"flag"
"fmt"
"io"
"io/ioutil"
"log"
"os"
"os/exec"
"path"
"path/filepath"
"regexp"
"runtime"
...
...
@@ -27,6 +27,10 @@ var (
version
string
=
"2.0.0-alpha"
race
bool
workingDir
string
installRoot
=
"/opt/grafana"
configRoot
=
"/etc/grafana"
grafanaLogDir
=
"/var/log/grafana"
)
const
minGoVersion
=
1.3
...
...
@@ -35,15 +39,7 @@ func main() {
log
.
SetOutput
(
os
.
Stdout
)
log
.
SetFlags
(
0
)
if
os
.
Getenv
(
"GOPATH"
)
==
""
{
cwd
,
err
:=
os
.
Getwd
()
if
err
!=
nil
{
log
.
Fatal
(
err
)
}
gopath
:=
filepath
.
Clean
(
filepath
.
Join
(
cwd
,
"../../../../"
))
log
.
Println
(
"GOPATH is"
,
gopath
)
os
.
Setenv
(
"GOPATH"
,
gopath
)
}
ensureGoPath
()
//os.Setenv("PATH", fmt.Sprintf("%s%cbin%c%s", os.Getenv("GOPATH"), os.PathSeparator, os.PathListSeparator, os.Getenv("PATH")))
...
...
@@ -73,8 +69,11 @@ func main() {
test
(
"./pkg/..."
)
case
"package"
:
test
(
"./pkg/..."
)
build
(
"."
,
[]
string
{})
//checkCleanTree()
//test("./pkg/...")
//build(".", []string{})
//buildFrontend()
createRpmAndDeb
()
case
"build-ui"
:
buildFrontend
()
...
...
@@ -87,17 +86,102 @@ func main() {
}
}
func
createRpmAndDeb
()
{
packageRoot
,
_
:=
ioutil
.
TempDir
(
""
,
"grafana-linux-pack"
)
postInstallScriptPath
,
_
:=
ioutil
.
TempFile
(
""
,
"postinstall"
)
versionFolder
:=
filepath
.
Join
(
packageRoot
,
installRoot
,
"versions"
,
version
)
runError
(
"mkdir"
,
"-p"
,
versionFolder
)
runError
(
"mkdir"
,
"-p"
,
filepath
.
Join
(
packageRoot
,
configRoot
))
runError
(
"cp"
,
"-a"
,
filepath
.
Join
(
workingDir
,
"tmp"
)
+
"/."
,
versionFolder
)
fmt
.
Printf
(
"PackageDir: %v
\n
"
,
versionFolder
)
GeneratePostInstallScript
(
postInstallScriptPath
.
Name
())
fmt
.
Printf
(
"script_path: %v
\n
"
,
postInstallScriptPath
.
Name
())
args
:=
[]
string
{
"-s"
,
"dir"
,
"-t"
,
"deb"
,
"--description"
,
"Grafana"
,
"-C"
,
packageRoot
,
"--vendor"
,
"Grafana"
,
"--url"
,
"http://grafana.org"
,
"--license"
,
"Apache 2.0"
,
"--maintainer"
,
"contact@grafana.org"
,
"--after-install"
,
postInstallScriptPath
.
Name
(),
"--name"
,
"grafana"
,
"--version"
,
version
,
"-p"
,
"./dist"
,
"."
,
}
runPrint
(
"fpm"
,
args
...
)
}
func
GeneratePostInstallScript
(
path
string
)
{
content
:=
`
rm -f $INSTALL_ROOT_DIR/grafana
rm -f $INSTALL_ROOT_DIR/init.sh
ln -s $INSTALL_ROOT_DIR/versions/$VERSION/grafana $INSTALL_ROOT_DIR/grafana
ln -s $INSTALL_ROOT_DIR/versions/$VERSION/scripts/init.sh $INSTALL_ROOT_DIR/init.sh
if [ ! -L /etc/init.d/grafana ]; then
ln -sfn $INSTALL_ROOT_DIR/init.sh /etc/init.d/grafana
chmod +x /etc/init.d/grafana
if which update-rc.d > /dev/null 2>&1 ; then
update-rc.d -f grafana remove
update-rc.d grafana defaults
else
chkconfig --add grafana
fi
fi
if ! id grafana >/dev/null 2>&1; then
useradd --system -U -M grafana
fi
chown -R -L grafana:grafana $INSTALL_ROOT_DIR
chmod -R a+rX $INSTALL_ROOT_DIR
mkdir -p $GRAFANA_LOG_DIR
chown -R -L grafana:grafana $GRAFANA_LOG_DIR
`
content
=
strings
.
Replace
(
content
,
"$INSTALL_ROOT_DIR"
,
installRoot
,
-
1
)
content
=
strings
.
Replace
(
content
,
"$VERSION"
,
version
,
-
1
)
content
=
strings
.
Replace
(
content
,
"$GRAFANA_LOG_DIR"
,
grafanaLogDir
,
-
1
)
ioutil
.
WriteFile
(
path
,
[]
byte
(
content
),
0644
)
}
func
checkCleanTree
()
{
rs
,
err
:=
runError
(
"git"
,
"ls-files"
,
"--modified"
)
if
err
!=
nil
{
log
.
Fatalf
(
"Failed to check if git tree was clean, %v, %v
\n
"
,
string
(
rs
),
err
)
return
}
count
:=
len
(
string
(
rs
))
if
count
>
0
{
log
.
Fatalf
(
"Git repository has modified files, aborting"
)
}
log
.
Fatalf
(
"Git repository is clean"
)
}
func
ensureGoPath
()
{
if
os
.
Getenv
(
"GOPATH"
)
==
""
{
cwd
,
err
:=
os
.
Getwd
()
if
err
!=
nil
{
log
.
Fatal
(
err
)
}
gopath
:=
filepath
.
Clean
(
filepath
.
Join
(
cwd
,
"../../../../"
))
log
.
Println
(
"GOPATH is"
,
gopath
)
os
.
Setenv
(
"GOPATH"
,
gopath
)
}
}
func
ChangeWorkingDir
(
dir
string
)
{
os
.
Chdir
(
dir
)
}
func
buildFrontend
()
{
ChangeWorkingDir
(
path
.
Join
(
workingDir
,
"grafana"
))
defer
func
()
{
ChangeWorkingDir
(
path
.
Join
(
workingDir
,
"../"
))
}()
runPrint
(
"grunt"
)
runPrint
(
"grunt"
,
"release"
)
}
func
setup
()
{
...
...
docker/debtest/Dockerfile
0 → 100644
View file @
ad2065af
FROM
debian:jessie
ADD
*.deb /tmp/
docker/debtest/build.sh
0 → 100755
View file @
ad2065af
#!/bin/bash
cp Dockerfile ../../dist
cd
../../dist
docker build
--tag
"grafana/debtest"
.
rm Dockerfile
docker run
-i
-t
grafana/debtest /bin/bash
pkg/util/encoding_test.go
View file @
ad2065af
...
...
@@ -11,6 +11,6 @@ func TestEncoding(t *testing.T) {
Convey
(
"When generating base64 header"
,
t
,
func
()
{
result
:=
GetBasicAuthHeader
(
"grafana"
,
"1234"
)
So
(
result
,
ShouldEqual
,
"Z3JhZmFuYToxMjM0"
)
So
(
result
,
ShouldEqual
,
"
Basic
Z3JhZmFuYToxMjM0"
)
})
}
scripts/init.sh
0 → 100644
View file @
ad2065af
#!/bin/sh
### BEGIN INIT INFO
# Provides: grafana
# Required-Start: $local_fs $remote_fs $network
# Required-Stop: $local_fs $remote_fs $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Starts grafana at startup
# Description: Starts grafana at startup
### END INIT INFO
# Documentation available at
# http://refspecs.linuxfoundation.org/LSB_3.1.0/LSB-Core-generic/LSB-Core-generic/iniscrptfunc.html
# Debian provides some extra functions though
.
/lib/lsb/init-functions
DAEMON_NAME
=
"grafana"
DAEMON_USER
=
"grafana"
DAEMON_PATH
=
"%BIN_PATH%"
DAEMON_OPTS
=
"web"
DAEMON_PWD
=
"/opt/grafana"
DAEMON_PID
=
"/var/run/
${
DAEMON_NAME
}
.pid"
DAEMON_NICE
=
0
DAEMON_LOG
=
'/var/log/grafana/grafana.log'
[
-r
"/etc/default/
${
DAEMON_NAME
}
"
]
&&
.
"/etc/default/
${
DAEMON_NAME
}
"
do_start
()
{
local
result
pidofproc
-p
"
${
DAEMON_PID
}
"
"
${
DAEMON_PATH
}
"
>
/dev/null
if
[
$?
-eq
0
]
;
then
log_warning_msg
"
${
DAEMON_NAME
}
is already started"
result
=
0
else
log_daemon_msg
"Starting
${
DAEMON_DESC
}
"
"
${
DAEMON_NAME
}
"
touch
"
${
DAEMON_LOG
}
"
chown
$DAEMON_USER
"
${
DAEMON_LOG
}
"
chmod u+rw
"
${
DAEMON_LOG
}
"
if
[
-z
"
${
DAEMON_USER
}
"
]
;
then
start-stop-daemon
--start
--quiet
--oknodo
--background
\
--nicelevel
$DAEMON_NICE
\
--chdir
"
${
DAEMON_PWD
}
"
\
--pidfile
"
${
DAEMON_PID
}
"
--make-pidfile
\
--exec
"
${
DAEMON_PATH
}
"
--
-c
$DAEMON_OPTS
result
=
$?
else
start-stop-daemon
--start
--quiet
--oknodo
--background
\
--nicelevel
$DAEMON_NICE
\
--chdir
"
${
DAEMON_PWD
}
"
\
--pidfile
"
${
DAEMON_PID
}
"
--make-pidfile
\
--chuid
"
${
DAEMON_USER
}
"
\
--exec
"
${
DAEMON_PATH
}
"
--
-c
${
DAEMON_OPTS
}
result
=
$?
fi
log_end_msg
$result
fi
return
$result
}
do_stop
()
{
local
result
pidofproc
-p
"
${
DAEMON_PID
}
"
"
${
DAEMON_PATH
}
"
>
/dev/null
if
[
$?
-ne
0
]
;
then
log_warning_msg
"
${
DAEMON_NAME
}
is not started"
result
=
0
else
log_daemon_msg
"Stopping
${
DAEMON_DESC
}
"
"
${
DAEMON_NAME
}
"
killproc
-p
"
${
DAEMON_PID
}
"
"
${
DAEMON_PATH
}
"
result
=
$?
log_end_msg
$result
rm
"
${
DAEMON_PID
}
"
fi
return
$result
}
do_restart
()
{
local
result
do_stop
result
=
$?
if
[
$result
=
0
]
;
then
do_start
result
=
$?
fi
return
$result
}
do_status
()
{
local
result
status_of_proc
-p
"
${
DAEMON_PID
}
"
"
${
DAEMON_PATH
}
"
"
${
DAEMON_NAME
}
"
result
=
$?
return
$result
}
do_usage
()
{
echo
$"Usage:
$0
{start | stop | restart | status}"
exit
1
}
case
"
$1
"
in
start
)
do_start
;
exit
$?
;;
stop
)
do_stop
;
exit
$?
;;
restart
)
do_restart
;
exit
$?
;;
status
)
do_status
;
exit
$?
;;
*
)
do_usage
;
exit
1
;;
esac
src/app/plugins/datasource/influxdb_08/partials/config.html
View file @
ad2065af
<h
2>
InfluxDB Details
</h2
>
<h
5>
InfluxDB Details
</h5
>
<div
class=
"tight-form"
>
<ul
class=
"tight-form-list"
>
...
...
@@ -6,29 +6,24 @@
Database
</li>
<li>
<input
type=
"text"
class=
"tight-form-input input-
xxlarge last
"
ng-model=
'current.database'
placeholder=
""
required
></input>
<input
type=
"text"
class=
"tight-form-input input-
large
"
ng-model=
'current.database'
placeholder=
""
required
></input>
</li>
</ul>
<div
class=
"clearfix"
></div>
</div>
<div
class=
"tight-form"
>
<div
class=
"tight-form
last
"
>
<ul
class=
"tight-form-list"
>
<li
class=
"tight-form-item"
style=
"width: 80px"
>
User
</li>
<li>
<input
type=
"text"
class=
"tight-form-input input-
xxlarge last
"
ng-model=
'current.user'
placeholder=
""
required
></input>
<input
type=
"text"
class=
"tight-form-input input-
large
"
ng-model=
'current.user'
placeholder=
""
required
></input>
</li>
</ul>
<div
class=
"clearfix"
></div>
</div>
<div
class=
"tight-form last"
>
<ul
class=
"tight-form-list"
>
<li
class=
"tight-form-item"
style=
"width: 80px"
>
<li
class=
"tight-form-item"
>
Password
</li>
<li>
<input
type=
"text"
class=
"tight-form-input input-
xxlarge last
"
ng-model=
'current.password'
placeholder=
""
required
></input>
<input
type=
"text"
class=
"tight-form-input input-
large
"
ng-model=
'current.password'
placeholder=
""
required
></input>
</li>
</ul>
<div
class=
"clearfix"
></div>
...
...
tasks/build_task.js
View file @
ad2065af
...
...
@@ -43,7 +43,7 @@ module.exports = function(grunt) {
});
grunt
.
config
(
'copy.backend_files'
,
{
expand
:
true
,
src
:
[
'conf/grafana.ini'
,
'vendor/**/*'
],
src
:
[
'conf/grafana.ini'
,
'vendor/**/*'
,
'scripts/*'
],
options
:
{
mode
:
true
},
dest
:
'<%= tempDir %>'
});
...
...
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