#!/bin/sh
cd /data

/bin/rm -rf *

/bin/mkdir -p -m 0777 public tmp
/bin/mkdir -p -m 0755 app appinfo etc opt
/bin/mkdir -p -m 0750 property
/bin/mkdir -p -m 0700 security
/bin/mkdir -p -m 0775 etc/ts var/opt

# chown
/bin/chown 1:1 etc/ts
/bin/chown 999:999 opt appinfo var/opt
/bin/chown 0:0 security

/bin/cat << EOD > /data/etc/group
root:x:0:
system:x:1:MAINAPP
hwdev:x:2:system,SUBAPP,MAINAPP
ped:x:3:
nobody:x:900:
SUBAPP:x:998:
MAINAPP:x:999:
EOD
/bin/chmod 0644 /data/etc/group

/bin/cat << EOD > /data/etc/passwd
root:x:0:0:root:/root:/bin/sh
system:x:1:1:administrator:/:/bin/false
hwdev:x:2:2:hardware access:/bin:/bin/false
ped:x:3:3:ped:/:/bin/false
nobody:x:900:900:nobody:/:/bin/false
SUBAPP:x:998:998:SUBAPP user:/:/bin/false
MAINAPP:x:999:999:MAINAPP user:/:/bin/sh
EOD
/bin/chmod 0644 /data/etc/passwd

/bin/cat << EOD > /data/etc/shadow
root:$1$9vCTc/8H$lRt/1/QoEXNamPGzhVGar/:0:0:99999:7:::
system:!$1$phzwtsL4$Qso0Z3H5eqoSUXwQ/hEAV1:0:0:99999:7:::
hwdev:!$1$jDG2WeUj$uM3mIyvZ1rkd11J7izXt6.:0:0:99999:7:::
ped:!$1$ZMsJtrjO$ibuMCiJvuyxQnrpkdptup/:0:0:99999:7:::
SUBAPP:!$1$gJUpez2c$U0Qv9IyoUAgD5cTSumbKB0:0:0:99999:7:::
MAINAPP:$1$wsdZqcgf$zD5mTBbZs.olBn7f02Wgf.:0:0:99999:7:::
EOD
/bin/chmod 0640 /data/etc/shadow

/bin/cat << EOD > /data/etc/ts/ts.conf
module_raw input
module pthres pmin=1
module variance delta=30
module dejitter delta=100
module linear
EOD
/bin/chmod 0644 /data/etc/ts/ts.conf

/bin/touch /data/.ready
/bin/sync
