-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure.sh
executable file
·44 lines (33 loc) · 985 Bytes
/
configure.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
#!/usr/bin/env sh
if [ $(id -u) -ne 0 ]; then
echo "This script needs to be run as root"
exit 1
fi
if [ $# -ne 4 ]; then
echo "Args: rootfs dir, username, hostname, sshpubkey"
echo "Example:"
echo " ./configure.sh rootfs bob computer /home/me/.ssh/id_ed25519.pub"
exit 1
fi
if [ ! -d $ROOTFS_DIR ]; then
echo "rootfs dir does not exist"
exit 1
fi
ROOTFS=$1
USERNAME=$2
HOSTNAME=$3
SSHKEY=$4
echo "#!/usr/bin/env sh" >${ROOTFS}/configure.sh
rv=$?; if [ $rv -ne 0 ]; then exit $rv; fi
echo USER=$USERNAME >>${ROOTFS}/configure.sh
rv=$?; if [ $rv -ne 0 ]; then exit $rv; fi
echo HOSTNAME=$HOSTNAME >>${ROOTFS}/configure.sh
rv=$?; if [ $rv -ne 0 ]; then exit $rv; fi
cat _configure.sh >>${ROOTFS}/configure.sh
rv=$?; if [ $rv -ne 0 ]; then exit $rv; fi
chmod +x ${ROOTFS}/configure.sh
rv=$?; if [ $rv -ne 0 ]; then exit $rv; fi
cp log2ram-*.tar.gz ${ROOTFS}/
rv=$?; if [ $rv -ne 0 ]; then exit $rv; fi
cp $SSHKEY ${ROOTFS}/
rv=$?; if [ $rv -ne 0 ]; then exit $rv; fi