添加 fake-automount for D2、C5

This commit is contained in:
Hyy2001X 2022-03-23 00:46:35 +08:00
parent 334c41097c
commit d333a208ca
4 changed files with 77 additions and 3 deletions

View File

@ -92,4 +92,5 @@ alias ll='ls -alF'
alias la='ls -A'
alias cls='clear'
alias dh='df -h'
alias syslog='cat /tmp/system.log 2> /dev/null'
alias ramfree='sync && echo 3 > /proc/sys/vm/drop_caches'

View File

@ -0,0 +1,69 @@
#!/bin/sh
LOGGER() {
echo $*
logger -t "automount[$$]" "$*"
}
[ -f /tmp/automount.pid ] && exit
echo "$$" > /tmp/automount.pid
case "$HOTPLUG_TYPE,$DEVTYPE" in
block,partition)
mkdir -p /var/log/automount
if [ "$ACTION" = remove ]
then
for disk in $(mount | awk '{print $1}' | grep /dev | egrep -v "mmcblk|mtdblock|loop");do
part=$(mount | grep $disk | awk '{print $3}')
[ ! "$part" ] && continue
skip_umount=$(lsblk --list $disk > /dev/null 2>&1; echo $?)
if [ "$skip_umount" = 0 -a "$force_umount" != 1 ]
then
LOGGER "Skip umounting [$part] ..."
continue
fi
umount $part 2> /dev/null || umount -l $part 2> /dev/null
sleep 1
LOGGER "Successfully umounted invisible part [$part]"
[ ! "$(ls -A $part)" ] && rm -rf $part
done
LOGGER "umount: Finished"
fi
if [ "$ACTION" = add ]
then
for part in $(lsblk --list | egrep -v "mmcblk|mtdblock" | grep part | awk '{print $1}');do
skip_mount=$(mount | awk '{print $1}' | grep -q $part ; echo $?)
fstype=$(block info /dev/$part | egrep -o 'TYPE="[0-9a-zA-Z].+' | awk -F '["]' '/TYPE/{print $2}')
if [ -z "$fstype" ]
then
LOGGER "Unknown filesystem type of [/dev/$part]"
continue
fi
if [ "$skip_mount" = 0 ]
then
LOGGER "Already mounted [/dev/$part] on this device"
continue
fi
mkdir -p /mnt/$part
chmod 777 /mnt/$part
case "$fstype" in
ntfs)
extra_cmd="-o nls=utf8"
;;
vfat)
extra_cmd="-o iocharset=utf8"
;;
esac
LOGGER "Try to mount disk [/dev/$part]($fstype) on [/mnt/$part] ..."
mount -t $fstype /dev/$part /mnt/$part -o rw,defaults $extra_cmd && LOGGER "Successfully mounted disk [/dev/$part] on [/mnt/$part]" || {
LOGGER "Failed to mount disk [/dev/$part] on [/mnt/$part]"
}
sleep 1
done
LOGGER "mount: Finished"
fi
;;
esac
rm -f /tmp/automount.pid
exit 0

View File

@ -66,6 +66,10 @@ Firmware_Diy() {
patch < ${CustomFiles}/${TARGET_PROFILE}_mac80211.patch -p1 -d ${Home}
Copy ${CustomFiles}/${TARGET_PROFILE}_system ${BASE_FILES}/etc/config system
sed -i "/DEVICE_COMPAT_VERSION := 1.1/d" target/linux/ramips/image/mt7621.mk
Copy ${CustomFiles}/fake-automount $(PKG_Finder d "package" automount)/files 15-automount
;;
xiaoyu_xy-c5)
Copy ${CustomFiles}/fake-automount $(PKG_Finder d "package" automount)/files 15-automount
;;
x86_64)
AddPackage git other openwrt-passwall xiaorouji main

View File

@ -499,11 +499,11 @@ Copy() {
MKDIR $2
if [[ -z $3 ]]
then
ECHO "Copying $1 to $2 ..."
ECHO "[C] Copying $1 to $2 ..."
cp -a $1 $2
else
ECHO "Copying and renaming $1 to $2/$3 ..."
ECHO "[R] Copying $1 to $2/$3 ..."
cp -a $1 $2/$3
fi
[[ $? == 0 ]] && ECHO "Done" || ECHO "Failed"
[[ $? == 0 ]] && ECHO "Done"
}