Skip to content

Commit

Permalink
Merge pull request #3 from jmtatsch/master
Browse files Browse the repository at this point in the history
Port scripts to rootfs
  • Loading branch information
EliasKotlyar authored Nov 12, 2018
2 parents 6abe4ff + d47bf68 commit dcffa06
Show file tree
Hide file tree
Showing 88 changed files with 3,260 additions and 828 deletions.
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
.idea/*
var/log/*
var/run/*
etc/*.conf
.ash_history
etc/dropbear/dropbear_ecdsa_host_key
etc/lighttpd.pem
etc/TZ
.ssh/*
1 change: 1 addition & 0 deletions etc/autonight.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-c /usr/scripts/nightmode.sh
2 changes: 2 additions & 0 deletions etc/autostart/auto-night-detection
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
/usr/controlscripts/auto-night-detection
2 changes: 2 additions & 0 deletions etc/autostart/rtsp-h264
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
/usr/controlscripts/rtsp-h264
111 changes: 92 additions & 19 deletions etc/init.d/rcS
Original file line number Diff line number Diff line change
Expand Up @@ -8,53 +8,95 @@ echo /sbin/mdev > /proc/sys/kernel/hotplug
#mknod -m 600 /dev/console c 5 1
#mknod -m 666 /dev/null c 1 3

# Set Global Environment
# Setup the global environment
export PATH=/bin:/sbin:/usr/bin:/usr/sbin
export PATH=/system/bin:$PATH
export PATH=$PATH:/opt/bin:/opt/sbin
export LD_LIBRARY_PATH=/system/lib
export LD_LIBRARY_PATH=/thirdlib:$LD_LIBRARY_PATH
LOGPATH="/var/log/startup.log"


# networking
ifconfig lo up
#ifconfig eth0 192.168.1.80
# ifconfig eth0 192.168.1.80

## Load some common functions:
. /usr/scripts/common_functions.sh
echo "Loaded common functions" >> $LOGPATH

# Start telnet daemon
telnetd &
# Start the telnet daemon
# telnetd &

# Set the system time from the hardware clock
#hwclock -s
# hwclock -s

#set the GPIO PC13 to high, make the USB Disk can be use
# Set the GPIO PC13 to high, make the USB Disk can be use
cd /sys/class/gpio
echo 77 > export #申请GPIO
cd gpio77
echo out > direction #设置为输出模式
echo 0 > active_low #value是0,表示低电平。value是1,表示高电平
echo 1 > value #设置电平(输出模式)

# Mount params partition
## Initialize the GPIOS:
for pin in 25 26 38 39 49; do
init_gpio $pin
done
# the ir_led pin is a special animal and needs active low
echo 1 > /sys/class/gpio/gpio49/active_low

echo "Initialized gpios" >> $LOGPATH

# Mount the params partition
mount -t jffs2 /dev/mtdblock9 /params

KERNEL_VERSION=$(uname -r)

# Start Network:
mount /dev/mmcblk0p1 /system/sdcard
MAC=$(grep MAC < /params/config/.product_config | cut -c16-27 | sed 's/\(..\)/\1:/g;s/:$//')
insmod /lib/modules/$KERNEL_VERSION/rtl8189es.ko rtw_initmac="$MAC"
# insmod /lib/modules/3.10.14/rtl8189fs.ko rtw_initmac="$MAC" # Uncomment for XiaoFang s1 && Wyzecam V2
# insmod /lib/modules/$KERNEL_VERSION/rtl8189fs.ko rtw_initmac="$MAC" # Uncomment for XiaoFang s1 && Wyzecam V2


if [ ! -f /etc/wpa_supplicant.conf ]; then
echo "Warning: You have to configure wpa_supplicant in order to use wifi. Please see /etc/wpa_supplicant.conf.dist for further instructions."
else
wpa_supplicant_status="$(wpa_supplicant -d -B -i wlan0 -c /etc/wpa_supplicant.conf -P /var/run/wpa_supplicant.pid)"
echo "wpa_supplicant: $wpa_supplicant_status" >> $LOGPATH
udhcpc_status=$(udhcpc -i wlan0 -p /var/run/udhcpc.pid -s /etc/udhcpc.script -b -x hostname:"$(hostname)")
echo "udhcpc: $udhcpc_status" >> $LOGPATH
fi

## Sync the via NTP:
if [ ! -f /etc/ntp_srv.conf ]; then
cp /etc/ntp_srv.conf.dist /etc/ntp_srv.conf
fi
ntp_srv="$(cat "/etc/ntp_srv.conf")"
busybox ntpd -p "$ntp_srv"

wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant.conf -P /var/run/wpa_supplicant.pid
udhcpc -i wlan0 -p /var/run/udhcpc.pid -s /etc/udhcpc.script -b -x hostname:"$(hostname)"
## Install busybox and dropbear applets
busybox --install
[ ! -e /usr/bin/ssh ] && ln -s dropbearmulti /usr/bin/ssh
[ ! -e /usr/bin/scp ] && ln -s dropbearmulti /usr/bin/scp
[ ! -e /usr/bin/dropbear ] && ln -s dropbearmulti /usr/bin/dropbear

# Start Motor:
insmod /lib/modules/$KERNEL_VERSION/sample_motor.ko

# Calibrate the motors for older models with endstops:
# motor hcalibrate
# motor vcalibrate

# Calibrate the motors for newer models without endstops:
# motor calibrate

# Determine the image sensor model:
insmod /lib/modules/$KERNEL_VERSION/sinfo.ko
echo 1 >/proc/jz/sinfo/info
sensor=$(grep -m1 -oE 'jxf[0-9]*$' /proc/jz/sinfo/info)
echo "Determined image sensor model as $sensor" >> $LOGPATH


# Start the image sensor:
insmod /lib/modules/$KERNEL_VERSION/tx-isp.ko isp_clk=100000000
Expand All @@ -65,11 +107,42 @@ else
fi

# Start User Applications:
bftpd -d
dropbearmulti dropbear -R
lighttpd -f /etc/lighttpd.conf

# Disable motion:
setconf -k m -v -1
# Start RTSP-Server without Audio:
v4l2rtspserver-master -A -W 1280 -H 960 &

## Start FTP & SSH Server:
dropbear_status=$(dropbearmulti dropbear -R)
echo "dropbear: $dropbear_status" >> $LOGPATH

bftpd_status=$(bftpd -d)
echo "bftpd: $bftpd_status" >> $LOGPATH

## Create a certificate for the webserver
if [ ! -f /etc/lighttpd.pem ]; then
export OPENSSL_CONF=/etc/openssl.cnf
openssl req -new -x509 -keyout /etc/lighttpd.pem -out /etc/lighttpd.pem -days 365 -nodes -subj "/C=DE/ST=Bavaria/L=Munich/O=.../OU=.../CN=.../emailAddress=..."
chmod 400 /etc/lighttpd.pem
echo "Created new certificate for webserver" >> $LOGPATH
fi

## Start Webserver:
if [ ! -f /etc/lighttpd.conf ]; then
cp /etc/lighttpd.conf.dist /etc/lighttpd.conf
fi
lighttpd_status=$(lighttpd -f /etc/lighttpd.conf)
echo "lighttpd: $lighttpd_status" >> $LOGPATH

## Configure OSD:
if [ -f /usr/controlscripts/configureOsd ]; then
. /usr/controlscripts/configureOsd 2>/dev/null
fi

## Configure Motion:
if [ -f /usr/controlscripts/configureMotion ]; then
. /usr/controlscripts/configureMotion 2>/dev/null
fi

## Autostart all enabled services:
for i in /etc/autostart/*; do
$i
done

echo "Startup finished!" >> $LOGPATH
File renamed without changes.
28 changes: 26 additions & 2 deletions etc/lighttpd.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
server.document-root = "/var/www/"
server.document-root = "/var/www"

server.port = 80

Expand All @@ -11,7 +11,8 @@ mimetype.assign = (
".jpg" => "image/jpeg",
".png" => "image/png",
".css" => "text/css",
".js" => "text/javascript"
".js" => "text/javascript",
".ico" => "image/x-icon"
)
index-file.names = ( "index.html" )
server.modules = ("mod_auth",
Expand All @@ -29,6 +30,29 @@ cgi.assign = ( ".cgi" => "/bin/sh" )



$SERVER["socket"] == ":443" {
ssl.engine = "enable"
ssl.pemfile = "/etc/lighttpd.pem"
}


# Support letsencrypt SSL cert paths
# (we don't want to upgrade to SSL nor auth' this path)
$HTTP["url"] !~ "^/.well-known/(.*)" {

auth.backend = "htdigest"
auth.backend.htdigest.userfile = "/etc/lighttpd.user"
auth.require = ( "/" => ("method" => "basic", "realm" => "all", "require" => "user=root"))

$HTTP["scheme"] == "http" {
# capture vhost name with regex conditiona -> %0 in redirect pattern
# must be the most inner block to the redirect rule
$HTTP["host"] =~ ".*" {
url.redirect = (".*" => "https://%0$0")
}
}
}

## enable debugging
#debug.log-request-header = "enable"
#debug.log-response-header = "enable"
Expand Down
2 changes: 2 additions & 0 deletions etc/lighttpd.user
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# by default root:ismart12
root:all:a6564902a687c445cbd80bab194c42d5
21 changes: 21 additions & 0 deletions etc/motion.conf.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
############################################################
# edit this file and move it to /etc/motion.conf #
############################################################

# Configure the motion core parameters:

region_of_interest=0,0,1280,720
motion_sensitivity=4
motion_indicator_color=2
motion_timeout=-1
motion_tracking=off

# Configure how to deal with motion events:

motion_trigger_led=true
save_snapshot=false
max_snapshots=20
publish_mqtt_message=false
sendemail=false
send_telegram=false
save_dir=/media/motion/stills
37 changes: 37 additions & 0 deletions etc/mqtt.conf.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
############################################################
# edit this file and move it to /etc/mqtt.conf #
############################################################

# Options for mosquitto_sub & mosquitto_pub
USER=mqtt-user
PASS=mqtt-password
HOST=mqtt-host
PORT=1883

# Define a location
LOCATION="myhome"

# Define device name
DEVICE_NAME="dafang"

# Define the base topic used by the camera
# send a message to myhome/dafang/set with the payload help for help.
# Results will be placed in myhome/dafang/${command} or topic/dafang/error - so please subscribe topic/dafang/# for testing purposes
TOPIC="$LOCATION/$DEVICE_NAME"

# Define an autodiscovery prefix, if autodiscovery is desired:
# AUTODISCOVERY_PREFIX="homeassistant"

# Define additional options for Mosquitto here.
# For example --cafile /etc/DST_Root_CA_X3.pem --tls-version tlsv1
# or use a special id to connect to brokers like azure
MOSQUITTOOPTS=""

# Add options for mosquitto_pub like -r for retaining messages
MOSQUITTOPUBOPTS=""

# Add options for curl here e.g --user user:password
CURLOPTS=""

# Send a mqtt statusupdate every n seconds
STATUSINTERVAL=30
1 change: 1 addition & 0 deletions etc/ntp_srv.conf.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
time.google.com
Loading

0 comments on commit dcffa06

Please sign in to comment.