-
Notifications
You must be signed in to change notification settings - Fork 4
/
debian-systemstart.sh
executable file
·59 lines (51 loc) · 1.72 KB
/
debian-systemstart.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash
### BEGIN INIT INFO
# Provides: systemstart
# Required-Start: mountkernfs
# Required-Stop:
# Default-Start: S
# Default-Stop:
# Short-Description: Initializes system if possible, such as console output over HDMI, hostname, sshd ca etc.
### END INIT INFO
. /lib/lsb/init-functions
systemstart_check_create_hostname() {
if [ ! -e "/etc/hostname" ]; then
mac=`cat /sys/class/net/eth0/address | sed s/://g`
hostname="debian-$mac"
log_action_begin_msg "Creating /etc/hostname with $hostname"
# mount -n -o remount,rw / || echo "Remounting / rw failed"
echo "$hostname" > /etc/hostname
hostname "$hostname"
if ! grep "^127.0.0.1\s*$hostname\s*" /etc/hosts > /dev/null ; then
sed -i "1i 127.0.0.1\\t$hostname" /etc/hosts
fi
# sync || echo "sync failed"
# mount -n -o remount,ro / || echo "Remounting / ro failed"
fi
}
systemstart_check_create_sshca() {
if [ ! -e /etc/ssh/ssh_host_rsa_key ]; then
log_action_msg "Generating SSH host keys..." || true
#mount -n -o remount,rw / || echo "Remounting / rw failed"
# dpkg-reconfigure openssh-server
ssh-keygen -A
#sync || echo "sync failed"
#mount -n -o remount,ro / || echo "Remounting / ro failed"
fi
}
case "$1" in
start)
# odroid c1
log_action_begin_msg "Enable console output over HDMI"
echo "0" > /sys/devices/platform/mesonfb/graphics/fb1/blank
# ** Overclock to 1.728 GHz
#echo 1728000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
systemstart_check_create_sshca
systemstart_check_create_hostname
log_action_end_msg 0
;;
*)
echo "Usage: /etc/init.d/$0 start"
exit 1
;;
esac