Add initial script
This commit is contained in:
commit
b8dcbff033
96
script.sh
Normal file
96
script.sh
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
|
||||||
|
set -e
|
||||||
|
set -x
|
||||||
|
|
||||||
|
RELEASE=19.07.6
|
||||||
|
|
||||||
|
wget -c https://downloads.openwrt.org/releases/$RELEASE/targets/ath79/generic/openwrt-imagebuilder-$RELEASE-ath79-generic.Linux-x86_64.tar.xz
|
||||||
|
tar xvf openwrt-imagebuilder-$RELEASE-ath79-generic.Linux-x86_64.tar.xz
|
||||||
|
|
||||||
|
cd openwrt-imagebuilder-$RELEASE-ath79-generic.Linux-x86_64
|
||||||
|
|
||||||
|
mkdir -p overlay/etc/uci-defaults
|
||||||
|
|
||||||
|
cat << \EOF > overlay/etc/profile
|
||||||
|
#!/bin/sh
|
||||||
|
[ -f /etc/banner ] && cat /etc/banner
|
||||||
|
[ -e /tmp/.failsafe ] && cat /etc/banner.failsafe
|
||||||
|
|
||||||
|
export PATH=/usr/bin:/usr/sbin:/bin:/sbin
|
||||||
|
export HOME=$(grep -e "^${USER:-root}:" /etc/passwd | cut -d ":" -f 6)
|
||||||
|
export HOME=${HOME:-/root}
|
||||||
|
export PS1='\u@\h:\w\$ '
|
||||||
|
|
||||||
|
[ -z "$KSH_VERSION" -o \! -s /etc/mkshrc ] || . /etc/mkshrc
|
||||||
|
[ -x /bin/more ] || alias more=less
|
||||||
|
[ -x /usr/bin/vim ] && alias vi=vim || alias vim=vi
|
||||||
|
[ -x /usr/bin/arp ] || arp() { cat /proc/net/arp; }
|
||||||
|
[ -x /usr/bin/ldd ] || ldd() { LD_TRACE_LOADED_OBJECTS=1 $*; }
|
||||||
|
|
||||||
|
HOSTNAME=$(uci get system.@system[0].hostname)
|
||||||
|
DOMAIN=$(uci -q get dhcp.@dnsmasq[0].domain)
|
||||||
|
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
FQDN=$HOSTNAME.$DOMAIN
|
||||||
|
else
|
||||||
|
FQDN=$HOSTNAME
|
||||||
|
fi
|
||||||
|
|
||||||
|
export PS1='\[\033[01;31m\]$FQDN\[\033[01;34m\] \W #\[\033[00m\] '
|
||||||
|
case "$TERM" in
|
||||||
|
xterm*|rxvt*)
|
||||||
|
echo -ne "\033]0;${USER}@${FQDN}:${PWD}\007"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Autogenerate hostname
|
||||||
|
cat << \EOF > overlay/etc/uci-defaults/40-hostname
|
||||||
|
HOSTNAME=cam-$(cat /sys/class/net/eth0/address | cut -d : -f 4- | sed -e 's/://g')
|
||||||
|
uci set system.@system[0].hostname=$HOSTNAME
|
||||||
|
uci set network.lan.hostname=$HOSTNAME
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Network interfaces config
|
||||||
|
cat << \EOF > overlay/etc/uci-defaults/50-access-point
|
||||||
|
# Disable DHCP servers
|
||||||
|
/etc/init.d/odhcpd disable
|
||||||
|
/etc/init.d/dnsmasq disable
|
||||||
|
|
||||||
|
# Remove firewall rules since AP bridges ethernet to wireless anyway
|
||||||
|
uci delete firewall.@zone[1]
|
||||||
|
uci delete firewall.@zone[0]
|
||||||
|
uci delete firewall.@forwarding[0]
|
||||||
|
for j in $(seq 0 10); do uci delete firewall.@rule[0]; done
|
||||||
|
|
||||||
|
# Remove LAN interface
|
||||||
|
uci delete network.lan
|
||||||
|
uci delete network.globals.ula_prefix
|
||||||
|
uci delete dhcp.@dnsmasq[0].domain
|
||||||
|
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Set mjpg-streamer defaults
|
||||||
|
cat << \EOF > overlay/etc/uci-defaults/90-mjpg-streamer
|
||||||
|
uci set mjpg-streamer.core.enabled='1'
|
||||||
|
uci set mjpg-streamer.core.resolution='1280x720'
|
||||||
|
uci set mjpg-streamer.core.fps='5'
|
||||||
|
uci delete mjpg-streamer.core.username
|
||||||
|
uci delete mjpg-streamer.core.password
|
||||||
|
EOF
|
||||||
|
|
||||||
|
cat << \EOF > overlay/etc/uci-defaults/99-k-space
|
||||||
|
# Add Lauri's Yubikey
|
||||||
|
echo 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDXOBCwD0Lj4ZmAhAxxvMNaElhYUvYh+qVBFAeZCzhOvyjpGXvGtDkdS6XmzpVBa5zgVb9WTAiH9JMNFQJlseyByAA++ISK7cILi+6vS+EtA0bungL6GrlwN1XXDjS5BLrv8m7cJC5xhHYXjEzOYzuhwzrk2uWuQ+eBSPBvy6gXcRt17m7rX0v+D6SlMbX+yjtSUSphHdsRyBv2beTh/wz8UZVBaRfCEX7mwkkWb8dYxjrgyNEMRxBiv62/SPo4iShrQz5jpMLNTrIfJTJnQCG8byOti7mHy+4Oai1nocIUaff/biJ/wchyc6j+VI1XjTriLyOgInBQrUxbF173Ko+Lh1KDONs3fOUGuHtDjcYmIdjotaLZPYx0fhFNAP9Xmm+FYvtTEGiXWI6uwvJnlILqhhhnuT91yPTv7P2XWoHz3x+p2yES+nP0vTVsJ6R0IoW9d1Wp0g6nsUSqEuQDM5s3ON65TX5wc3WJQ2CHYuEIRkwZoga61jtE0nesg2p/S2mB3KFn2jx0y9yTApBygTWJB2GgNciUEohAkr1Qt4lfl2JJOmFVpg0H6gMJBeLPzlugPc3xgQFHPR+8NoseGvtrV+mbPL/YKHM5Yy+c4Yw4DWUzh7TbRfCIw9YdHyes8eIv+w4WX2q0Ze7DbPrdYAmVqKIeYlEm1/ZH/2QXiG9fNQ== cardno:000608670822' > /etc/dropbear/authorized_keys
|
||||||
|
|
||||||
|
# Ping lauri for plaintext password, eg when there's issue camera
|
||||||
|
sed -i 's|^root::|root:$1$Ji4oV3An$2h4IhUFWhheefdaWEW.vg/:|' /etc/shadow
|
||||||
|
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Make image
|
||||||
|
make image PROFILE=glinet_gl-ar150 FILES=overlay/ PACKAGES="curl htop nano mjpg-streamer kmod-video-uvc \
|
||||||
|
v4l-utils tcpdump -odhcp6c -odhcpd -dnsmasq -pppd -luci-proto-ppp -kmod-ppp -ppp -ppp-mod-pppoe \
|
||||||
|
-kmod-ath -kmod-ath9k-common -kmod-ath9k -kmod-ip6tables -ip6tables -luci-proto-ipv6 -kmod-iptunnel6 -kmod-ipsec6 -luci"
|
Loading…
Reference in New Issue
Block a user