msnews
April 4, 2023, 9:28pm
1
Hello,
I have the following command inside uci-defaults/99-custom while building the squashfs image for rpi4:
#!/bin/sh
ln -s /usr/bin/ntfs-3g /sbin/mount.ntfs
mount -t ext4 /dev/mmcblk0p3 /opt
mount -t ntfs /dev/sda1 /mnt/sda1
ln -s /opt/scan /home
rm /opt/YAMon4/yamon
ln -s /tmp/yamon /opt/YAMon4/yamon
exit 0
Flash the image on sdcard and boot rpi4, the above commands don't work as expected. The problem is:
the link created has question mark after the filename i.e. home?, yamon? and mount.ntfs? and they are not working as well.
mount command doesn't mount the partition.
What is the wrong?
The first thing I usually do when using uci-default is to run the code, line by line, manually in the openwrt terminal to verify the function line by line.
If it doesn’t work there it doesn’t work in uci-default during boot.
But at least you will see any complains in plain text and you will be able to see where it derails.
msnews
April 5, 2023, 6:49am
4
If I exclude the script during image building and then run it after router has finished booting, it works without any problem.
The problem happens when they are included in the image.
msnews
April 5, 2023, 6:50am
5
I checked the script, it is in unix format. it has created the symbol link but just does work.
Insert the following code in the /etc/uci-defaults/99-custom
:
# Beginning
set -x -v; exec &> /root/custom.log
# End
exit 1
After the installation check this:
opkg update
opkg install coreutils-cat
cat -A /etc/uci-defaults/99-custom
cat -A /root/custom.log
1 Like
msnews
April 5, 2023, 5:51pm
7
thanks. so the script will be like this below?
#!/bin/sh
# Beginning
set -x -v; exec &> /root/custom.log
ln -s /usr/bin/ntfs-3g /sbin/mount.ntfs
mount -t ext4 /dev/mmcblk0p3 /opt
mount -t ntfs /dev/sda1 /mnt/sda1
ln -s /opt/scan /home
rm /opt/YAMon4/yamon
ln -s /tmp/yamon /opt/YAMon4/yamon
# End
exit 1
After installation:
root@pi4:/# cat -A /etc/uci-defaults/99-custom
^M$
#!/bin/sh^M$
# Beginning^M$
set -x -v; exec &> /root/custom.log^M$
^M$
^M$
ln -s /usr/bin/ntfs-3g /sbin/mount.ntfs^M$
mount -t ext4 /dev/mmcblk0p3 /opt^M$
mount -t ntfs /dev/sda1 /mnt/sda1^M$
ln -s /opt/scan /home^M$
rm /opt/YAMon4/yamon^M$
ln -s /tmp/yamon /opt/YAMon4/yamon^M$
^M$
# End^M$
exit 1^M$
^M$
I have the file custom.log? instead of custom.log . I could not open custom.log? file so I rename it to custom.log :
root@pi4:~# cat -A /root/custom.log
^M$
+ '^M'$
/etc/rc.common: ./99-custom: line 5: ^M: not found$
^M$
+ '^M'$
/etc/rc.common: ./99-custom: line 6: ^M: not found$
ln -s /usr/bin/ntfs-3g /sbin/mount.ntfs^M$
+ ln -s /usr/bin/ntfs-3g '/sbin/mount.ntfs^M'$
mount -t ext4 /dev/mmcblk0p3 /opt^M$
+ mount -t ext4 /dev/mmcblk0p3 '/opt^M'$
mount: mounting /dev/mmcblk0p3 on /opt^M failed: No such file or directory$
mount -t ntfs /dev/sda1 /mnt/sda1^M$
+ mount -t ntfs /dev/sda1 '/mnt/sda1^M'$
mount: mounting /dev/sda1 on /mnt/sda1^M failed: No such file or directory$
ln -s /opt/scan /home^M$
+ ln -s /opt/scan '/home^M'$
rm /opt/YAMon4/yamon^M$
+ rm '/opt/YAMon4/yamon^M'$
rm: can't remove '/opt/YAMon4/yamon^M': No such file or directory$
ln -s /tmp/yamon /opt/YAMon4/yamon^M$
+ ln -s /tmp/yamon '/opt/YAMon4/yamon^M'$
^M$
+ '^M'$
/etc/rc.common: ./99-custom: line 13: ^M: not found$
# End^M$
exit 1^M$
+ exit '1^M'$
/etc/rc.common: exit: line 15: Illegal number: 1^M$
root@pi4:~#
All "ln" commands created symbol link ended with "?", they are not working unless I remove the "?".
How did you "install" it ?
dos2unix might help here.
1 Like
msnews:
^M$
This is clearly the CR+LF
EOL.
You should convert the resulting script using the linked instructions.
1 Like
msnews
April 5, 2023, 7:54pm
10
Install means build a new image and flash to the sdcard.
msnews
April 6, 2023, 12:35am
11
You are right! I use notepad++ to save it to unix format and now it is working.
it is strange. I created it in ubuntu, it should default to unix format.
1 Like
system
Closed
April 16, 2023, 12:35am
12
This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.