. /usr/share/debconf/confmodule
db_version 2.0
+escape_json_string() {
+ LANG=C command -p awk '
+ BEGIN {
+ ORS = ""
+
+ for ( i = 1; i <= 127; i++ )
+ tr[ sprintf( "%c", i) ] = sprintf( "\\u%04x", i )
+
+ for ( i = 1; i < ARGC; i++ ) {
+ s = ARGV[i]
+ print "\""
+ while ( match( s, /[\001-\037\177"\\]/ ) ) {
+ print substr(s,1,RSTART-1) tr[ substr(s,RSTART,RLENGTH) ]
+ s = substr(s,RSTART+RLENGTH)
+ }
+ print s "\"\n"
+ }
+ }
+ ' "$@"
+}
+
case "$1" in
configure)
if ! getent passwd "$HTS_USER" >/dev/null; then
echo >>"$HTS_SUPERUSERCONF" "{"
if db_get tvheadend/admin_username; then
- echo >>"$HTS_SUPERUSERCONF" "\"username\": \"$RET\","
+ JSONUSER=`escape_json_string $RET`
+ echo "\"username\": $JSONUSER,"
+ JSONUSER=""
fi
if db_get tvheadend/admin_password; then
- echo >>"$HTS_SUPERUSERCONF" "\"password\": \"$RET\""
+ JSONPASS=`escape_json_string $RET`
+ echo "\"password\": $JSONPASS"
+ JSONPASS=""
fi
echo >>"$HTS_SUPERUSERCONF" "}"