Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MultiDB]: install default db config file when installing libswsscommon if there is no such a file #321

Merged
merged 1 commit into from
Dec 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if file exists we should copy this one one wih suffix ".new" to the same directory to indicate that there is new configuration, btw. i though that there is mechanism already in debian packages to do that, instead manually do that for each file, here is some nice explanation: https://raphaelhertzog.com/2010/09/21/debian-conffile-configuration-file-managed-by-dpkg/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can add suffix to save this conf, but we won’t use confines as explained under Qi’s comment, we don’t want prompt.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

if [ ! -e $DST_PATH/$DST_FILE ]; then
mkdir -p $DST_PATH
cp $SRC_PATH/$DST_FILE $DST_PATH/$DST_FILE
fi