Skip to content

Commit

Permalink
[MultiDB]: install default db config file when installing swsscommon …
Browse files Browse the repository at this point in the history
…lib if there is no one (#321)
  • Loading branch information
dzhangalibaba authored and kcudnik committed Dec 6, 2019
1 parent eb01b68 commit 29a2cdf
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 1 deletion.
3 changes: 2 additions & 1 deletion common/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ EXTRA_DIST = \
consumer_table_pops.lua \
producer_state_table_apply_view.lua \
table_dump.lua \
fdb_flush.lua
fdb_flush.lua \
database_config.json

swssdir = $(datadir)/swss

Expand Down
57 changes: 57 additions & 0 deletions common/database_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"INSTANCES": {
"redis":{
"hostname" : "127.0.0.1",
"port" : 6379,
"unix_socket_path" : "/var/run/redis/redis.sock"
}
},
"DATABASES" : {
"APPL_DB" : {
"id" : 0,
"separator": ":",
"instance" : "redis"
},
"ASIC_DB" : {
"id" : 1,
"separator": ":",
"instance" : "redis"
},
"COUNTERS_DB" : {
"id" : 2,
"separator": ":",
"instance" : "redis"
},
"LOGLEVEL_DB" : {
"id" : 3,
"separator": ":",
"instance" : "redis"
},
"CONFIG_DB" : {
"id" : 4,
"separator": "|",
"instance" : "redis"
},
"PFC_WD_DB" : {
"id" : 5,
"separator": ":",
"instance" : "redis"
},
"FLEX_COUNTER_DB" : {
"id" : 5,
"separator": ":",
"instance" : "redis"
},
"STATE_DB" : {
"id" : 6,
"separator": "|",
"instance" : "redis"
},
"SNMP_OVERLAY_DB" : {
"id" : 7,
"separator": "|",
"instance" : "redis"
}
},
"VERSION" : "1.0"
}
1 change: 1 addition & 0 deletions debian/libswsscommon.install
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
usr/lib/*/lib*.so.*
usr/share/swss/*.lua
usr/share/swss/*.json
usr/bin/swssloglevel
11 changes: 11 additions & 0 deletions debian/postinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
# This `DEBIAN/postinst` script is run post-installation
DST_PATH="/var/run/redis/sonic-db"
DST_FILE="database_config.json"
SRC_PATH="/usr/share/swss"

# if there is no $DST_FILE, it is needed to copy one default to $DST_FILE
if [ ! -e $DST_PATH/$DST_FILE ]; then
mkdir -p $DST_PATH
cp $SRC_PATH/$DST_FILE $DST_PATH/$DST_FILE
fi

0 comments on commit 29a2cdf

Please sign in to comment.