-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add pack.sh for packing the basic rootfs.img
- Loading branch information
Showing
5 changed files
with
149 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
*.bin | ||
rootfs.img | ||
tmp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
## 打包基础固件脚本 | ||
|
||
- uart 免密登录 | ||
- ssh 自动开启 | ||
- root 密码设置成 root | ||
|
||
需要安装 squashfs 相关的工具 | ||
|
||
```sh | ||
sudo ./pack.sh | ||
``` | ||
|
||
执行成功后会在本目录下生成一个 rootfs.img |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
BASE_DIR=`pwd` | ||
WORK_DIR=`pwd`/tmp | ||
#MD5SUM="1ae7eb1bdbb764b946654a08dfec1cac" | ||
URL="https://cdn.cnbj1.fds.api.mi-img.com/xiaoqiang/rom/lx01/mico_firmware_c1cac_1.56.1.bin" | ||
|
||
# if firmware.bin exists, skip download | ||
if [ -f mico_firmware_c1cac_1.56.1.bin ]; then | ||
echo "firmware.bin exists, skip download" | ||
else | ||
wget -c $URL | ||
fi | ||
|
||
rm -rf $WORK_DIR && mkdir -pv $WORK_DIR && ln -sf $BASE_DIR/mico_firmware_c1cac_1.56.1.bin $WORK_DIR/firmware.bin | ||
pushd $WORK_DIR | ||
|
||
dd if=firmware.bin bs=8 skip=524409 of=rootfs.img | ||
unsquashfs rootfs.img && rm -rf rootfs.img | ||
|
||
pushd squashfs-root | ||
|
||
PATCH_DIR=$BASE_DIR/patches | ||
PATCHES=`ls $PATCH_DIR/*.patch | sort -n` | ||
|
||
for patch in $PATCHES; do | ||
patch -p1 < $patch | ||
done | ||
|
||
popd | ||
|
||
mksquashfs squashfs-root rootfs.img -comp xz -b 256K -noappend && mv rootfs.img $BASE_DIR/rootfs.img | ||
|
||
popd | ||
|
||
rm -rf $WORK_DIR | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
diff --git a/etc/init.d/dropbear b/etc/init.d/dropbear | ||
index b2d2719..45eeb4f 100755 | ||
--- a/etc/init.d/dropbear | ||
+++ b/etc/init.d/dropbear | ||
@@ -53,8 +53,7 @@ dropbear_instance() | ||
MaxAuthTries mdns ipaddrs | ||
|
||
validate_section_dropbear "${1}" || { | ||
- echo "validation failed" | ||
+ echo "validation failed and skip" | ||
- return 1 | ||
} | ||
|
||
[ -n "${Interface}" ] && { | ||
@@ -64,7 +62,6 @@ dropbear_instance() | ||
} | ||
} | ||
|
||
- [ "${enable}" = "0" ] && return 1 | ||
PIDCOUNT="$(( ${PIDCOUNT} + 1))" | ||
local pid_file="/var/run/${NAME}.${PIDCOUNT}.pid" | ||
|
||
@@ -111,20 +108,12 @@ keygen() | ||
load_interfaces() | ||
{ | ||
config_get interface "$1" Interface | ||
- config_get enable "$1" enable 1 | ||
- | ||
- [ "${enable}" = "1" ] && interfaces=" ${interface} ${interfaces}" | ||
+ interfaces=" ${interface} ${interfaces}" | ||
} | ||
|
||
start_service() | ||
{ | ||
- ssh_en=`cat /data/ssh_en 2>/dev/null` | ||
- ssh_en_bind=`cat /data/.ssh_en 2>/dev/null` | ||
- ssh_en_tmp=`cat /tmp/ssh_en 2>/dev/null` | ||
- channel=`micocfg_channel 2>/dev/null` | ||
- if [ "$ssh_en" != "1" -a "$ssh_en_bind" != "1" -a "$ssh_en_tmp" != "1" -a "$channel" = "release" ]; then | ||
- return 0 | ||
- fi | ||
+ mkdir -p /data/etc/dropbear | ||
[ -s /data/etc/dropbear/dropbear_rsa_host_key ] || keygen | ||
|
||
. /lib/functions.sh | ||
diff --git a/etc/inittab b/etc/inittab | ||
index 7a6c352..94276b8 100644 | ||
--- a/etc/inittab | ||
+++ b/etc/inittab | ||
@@ -1,3 +1,3 @@ | ||
::sysinit:/etc/init.d/rcS S boot | ||
::shutdown:/etc/init.d/rcS K shutdown | ||
-::askconsole:/bin/login | ||
+::askconsole:/bin/sh --login | ||
diff --git a/etc/pam.d/common-auth b/etc/pam.d/common-auth | ||
index 111e32a..c610144 100644 | ||
--- a/etc/pam.d/common-auth | ||
+++ b/etc/pam.d/common-auth | ||
@@ -8,10 +8,10 @@ | ||
# traditional Unix authentication mechanisms. | ||
# | ||
|
||
-auth sufficient libmico-pam.so | ||
-account sufficient libmico-pam.so | ||
+#auth sufficient libmico-pam.so | ||
+#account sufficient libmico-pam.so | ||
# here are the per-package modules (the "Primary" block) | ||
-# auth [success=1 default=ignore] pam_unix.so nullok_secure | ||
+ auth [success=1 default=ignore] pam_unix.so nullok_secure | ||
# here's the fallback if no module succeeds | ||
auth requisite pam_deny.so | ||
# prime the stack with a positive return value if there isn't one already; | ||
diff --git a/etc/rc.d/S99dropbear b/etc/rc.d/S99dropbear | ||
new file mode 120000 | ||
index 0000000..44af88d | ||
--- /dev/null | ||
+++ b/etc/rc.d/S99dropbear | ||
@@ -0,0 +1 @@ | ||
+../init.d/dropbear | ||
\ No newline at end of file | ||
diff --git a/etc/shadow b/etc/shadow | ||
index 9383c5d..058f9df 100644 | ||
--- a/etc/shadow | ||
+++ b/etc/shadow | ||
@@ -1,4 +1,4 @@ | ||
-root:$1$6QTE6j6z$lVroJsorN7M7F2h1mrdIS0:18128:0:99999:7::: | ||
+root:$1$xiaoai$803hWklCcQwX7v5gYP6pB0:18128:0:99999:7::: | ||
daemon:*:0:0:99999:7::: | ||
ftp:*:0:0:99999:7::: | ||
network:*:0:0:99999:7::: |