Commit c4a9c76f authored by Yuri Aksenov's avatar Yuri Aksenov
Browse files

Init datacollector

parent 3f936fb6
This diff is collapsed.
../configs/cifs
\ No newline at end of file
../configs/nfs
\ No newline at end of file
../configs/cifs
\ No newline at end of file
../configs/nfs
\ No newline at end of file
../configs/cifs
\ No newline at end of file
../configs/nfs
\ No newline at end of file
CONFIG_NETWORK_FILESYSTEMS=y
CONFIG_CIFS=y
CONFIG_BLK_DEV_INITRD=y
CONFIG_INITRAMFS_SOURCE="/kernelconfig/initramfs/initramfs_list"
CONFIG_INITRAMFS_ROOT_UID=0
CONFIG_INITRAMFS_ROOT_GID=0
CONFIG_RD_GZIP=y
CONFIG_INITRAMFS_COMPRESSION=".gz"
CONFIG_DEVTMPFS=y
CONFIG_NETWORK_FILESYSTEMS=y
CONFIG_NFS_FS=y
#!/bin/sh
cmdline() {
local value
value=" $(cat /proc/cmdline) "
value="${value##* $1=}"
value="${value%% *}"
[ "$value" != "" ] && echo "$value"
}
rootdevice() {
local value
value="$(lsblk -no pkname $1)"
[ "$value" != "" ] && echo "/dev/$value"
}
freespaceafter() {
local escaped
local start
escaped="$(echo ""$2"" | sed 's|/|\\/|g')"
start="$(sfdisk -d $1 | sed -n "/$escaped/p" | sed -r 's/.*start=\s*([0-9]+),.*/\1/g')"
sfdisk -q -F $1 | sed -n '/^\s*[0-9]/p' | sed -r 's/^\s*([0-9]+)\s.*/\1/g' | while read freespace
do
if [ $freespace -gt $start ]; then
echo "available"
break
fi
done
}
maximize() {
local escaped
escaped="$(echo ""$2"" | sed 's|/|\\/|g')"
sfdisk -d $1 | sed "/$escaped/ s/,\ssize=.*//g" | sfdisk $1 > /dev/null 2> /dev/null
fsck.ext4 -f -y $2 > /dev/null 2> /dev/null
resize2fs $2 > /dev/null 2> /dev/null
}
mount -t devtmpfs devtmpfs /dev
mount -t proc proc /proc
mount -t sysfs sysfs /sys
mount -t tmpfs tmpfs /run
root=$(cmdline root)
if [ -z $root ]; then
echo "No valid root= is provided on kernel command line"
else
rootfs=$(findfs $root)
if [ -b $rootfs ]; then
mount -o ro $rootfs /mnt/root
datafs=$(findmnt -s -no source /data)
if [ -b $datafs ]; then
rootdevice=$(rootdevice $datafs)
freespace=$(freespaceafter $rootdevice $datafs)
if [ "$freespace" = "available" ]; then
echo "Resizing data partition $datafs"
umount /mnt/root
maximize $rootdevice $datafs
mount -o ro $rootfs /mnt/root
fi
mount /data
if [ -f /data/.factorydefault ]; then
echo "Resetting data partition to factory default"
umount /data
cat /mnt/root/usr/share/factorydefault/data.xz | unxz > $datafs
fsck.ext4 -f -y $datafs > /dev/null 2> /dev/null
resize2fs $datafs > /dev/null 2> /dev/null
mount /data
fi
mount --move /dev /mnt/root/dev
mount --move /proc /mnt/root/proc
mount --move /sys /mnt/root/sys
mount --move /run /mnt/root/run
mount --move /data /mnt/root/data
exec switch_root /mnt/root /sbin/init
else
echo "Cannot find file system for data partition"
fi
else
echo "Cannot find file system for root $root"
fi
fi
dir /dev 755 0 0
nod /dev/console 644 0 0 c 5 1
dir /proc 755 0 0
dir /sys 755 0 0
dir /run 755 0 0
dir /mnt 755 0 0
dir /mnt/root 755 0 0
dir /data 755 0 0
dir /etc 755 0 0
slink /etc/mtab /proc/self/mounts 777 0 0
slink /etc/fstab /mnt/root/etc/fstab 777 0 0
dir /lib 755 0 0
file /lib/libreadline.so.7.0 /lib/libreadline.so.7.0 555 0 0
slink /lib/libreadline.so.7 libreadline.so.7.0 777 0 0
file /lib/libhistory.so.7.0 /lib/libhistory.so.7.0 555 0 0
slink /lib/libhistory.so.7 libhistory.so.7.0 777 0 0
file /lib/libncursesw.so.6.1 /lib/libncursesw.so.6.1 755 0 0
slink /lib/libncursesw.so.6 libncursesw.so.6.1 777 0 0
file /lib/libdl-2.27.so /lib/libdl-2.27.so 755 0 0
slink /lib/libdl.so.2 libdl-2.27.so 777 0 0
file /lib/libc-2.27.so /lib/libc-2.27.so 755 0 0
slink /lib/libc.so.6 libc-2.27.so 777 0 0
file /lib/ld-2.27.so /lib/ld-2.27.so 755 0 0
slink /lib/ld-linux-armhf.so.3 ld-2.27.so 777 0 0
slink /lib/ld-linux-aarch64.so.1 ld-2.27.so 777 0 0
slink /lib/ld-linux-x86-64.so.2 ld-2.27.so 777 0 0
file /lib/libmount.so.1.1.0 /lib/libmount.so.1.1.0 755 0 0
slink /lib/libmount.so.1 libmount.so.1.1.0 777 0 0
file /lib/libblkid.so.1.1.0 /lib/libblkid.so.1.1.0 755 0 0
slink /lib/libblkid.so.1 libblkid.so.1.1.0 777 0 0
file /lib/libuuid.so.1.3.0 /lib/libuuid.so.1.3.0 755 0 0
slink /lib/libuuid.so.1 libuuid.so.1.3.0 777 0 0
file /lib/librt-2.27.so /lib/librt-2.27.so 755 0 0
slink /lib/librt.so.1 librt-2.27.so 777 0 0
file /lib/libpthread-2.27.so /lib/libpthread-2.27.so 755 0 0
slink /lib/libpthread.so.0 libpthread-2.27.so 777 0 0
file /lib/libsmartcols.so.1.1.0 /lib/libsmartcols.so.1.1.0 755 0 0
slink /lib/libsmartcols.so.1 libsmartcols.so.1.1.0 777 0 0
file /lib/libacl.so.1.1.0 /lib/libacl.so.1.1.0 755 0 0
slink /lib/libacl.so.1 libacl.so.1.1.0 777 0 0
file /lib/libattr.so.1.1.0 /lib/libattr.so.1.1.0 755 0 0
slink /lib/libattr.so.1 libattr.so.1.1.0 777 0 0
file /lib/libfdisk.so.1.1.0 /lib/libfdisk.so.1.1.0 755 0 0
slink /lib/libfdisk.so.1 libfdisk.so.1.1.0 777 0 0
file /lib/libext2fs.so.2.4 /lib/libext2fs.so.2.4 755 0 0
slink /lib/libext2fs.so.2 libext2fs.so.2.4 777 0 0
file /lib/libcom_err.so.2.1 /lib/libcom_err.so.2.1 755 0 0
slink /lib/libcom_err.so.2 libcom_err.so.2.1 777 0 0
file /lib/libe2p.so.2.3 /lib/libe2p.so.2.3 755 0 0
slink /lib/libe2p.so.2 libe2p.so.2.3 777 0 0
file /lib/liblzma.so.5.2.4 /lib/liblzma.so.5.2.4 755 0 0
slink /lib/liblzma.so.5 liblzma.so.5.2.4 777 0 0
dir /bin 755 0 0
file /bin/bash /bin/bash 755 0 0
slink /bin/sh bash 777 0 0
file /bin/cat /bin/cat 755 0 0
file /bin/[ /bin/[ 755 0 0
file /bin/echo /bin/echo 755 0 0
file /bin/mount /bin/mount 755 0 0
file /bin/umount /bin/umount 755 0 0
file /bin/findfs /sbin/findfs 755 0 0
file /bin/findmnt /bin/findmnt 755 0 0
file /bin/switch_root /sbin/switch_root 755 0 0
file /bin/lsblk /bin/lsblk 755 0 0
file /bin/sed /bin/sed 755 0 0
file /bin/sfdisk /sbin/sfdisk 755 0 0
file /bin/fsck.ext4 /sbin/fsck.ext4 755 0 0
file /bin/resize2fs /sbin/resize2fs 755 0 0
file /bin/unxz /bin/unxz 755 0 0
file /init /init 755 0 0
#!/bin/sh
mkdir -p /kernelconfig/initramfs/lib
mkdir -p /kernelconfig/initramfs/bin
mkdir -p /kernelconfig/initramfs/sbin
grep "^file /lib" /kernelconfig/initramfs/initramfs.list | awk '{print $3" -o /kernelconfig/initramfs"$3}' | xargs -n3 strip --strip-debug
grep "^file /bin" /kernelconfig/initramfs/initramfs.list | awk '{print $3" -o /kernelconfig/initramfs"$3}' | xargs -n3 strip --strip-all
sed '/^file/ s/^file [^[:space:]]\{1,\} /&\/kernelconfig\/initramfs/' /kernelconfig/initramfs/initramfs.list > /kernelconfig/initramfs/initramfs_list
../configs/cifs
\ No newline at end of file
../configs/initramfs
\ No newline at end of file
../configs/nfs
\ No newline at end of file
../configs/cifs
\ No newline at end of file
../configs/initramfs
\ No newline at end of file
../configs/nfs
\ No newline at end of file
../configs/cifs
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment