cryptpad/container-start.sh

29 lines
933 B
Bash
Raw Normal View History

2017-04-09 17:36:33 +08:00
#!/bin/sh
2016-12-30 05:02:03 +08:00
# Creating customize folder
mkdir -p customize
2017-04-09 17:36:33 +08:00
[ -z "$(ls -A customize)" ] && echo "Creating customize folder" \
2016-12-30 05:02:03 +08:00
&& cp -R customize.dist/* customize/ \
2017-04-25 22:04:17 +08:00
&& cp config.example.js customize/config.js
2016-12-30 05:02:03 +08:00
2017-04-25 22:04:17 +08:00
# Linking config.js
2017-04-09 17:36:33 +08:00
[ ! -h config.js ] && echo "Linking config.js" && ln -s customize/config.js config.js
2016-12-30 05:02:03 +08:00
# Thanks to http://stackoverflow.com/a/10467453
sedeasy() {
sed -i "s/$1/$(echo $2 | sed -e 's/[\/&]/\\&/g')/g" $3
}
2017-04-25 22:04:17 +08:00
# Configure
2017-04-09 17:36:33 +08:00
[ -n "$USE_SSL" ] && echo "Using secure websockets: $USE_SSL" \
&& sedeasy "useSecureWebsockets: [^,]*," "useSecureWebsockets: ${USE_SSL}," customize/config.js
2016-12-30 05:02:03 +08:00
2017-04-09 17:36:33 +08:00
[ -n "$STORAGE" ] && echo "Using storage adapter: $STORAGE" \
&& sedeasy "storage: [^,]*," "storage: ${STORAGE}," customize/config.js
2016-12-30 05:02:03 +08:00
2017-04-09 17:36:33 +08:00
[ -n "$LOG_TO_STDOUT" ] && echo "Logging to stdout: $LOG_TO_STDOUT" \
&& sedeasy "logToStdout: [^,]*," "logToStdout: ${LOG_TO_STDOUT}," customize/config.js
2016-12-30 05:02:03 +08:00
2017-04-09 04:08:38 +08:00
exec node ./server.js