#!/bin/bash
samba_share_path=${HOME}/samba_share samba_user_name=${USER} temp_file=${HOME}/temp.txt samba_mount_path=${HOME}/samba_mount
# 三、openwrt的samba # (1)编译选择 #make menuconfig # 1.内核选择cifs # Kernel modules -->Filesystems --><*>kmod-fs-cifs. CIFS support
# 2.samba36的客户端和服务端 # Network --><*>samba36-client. Samba 3.6 SMB/CIFS client # <*>samba36-hotplug. Samba 3.6 SMB/CIFS hotplug # <*>samba36-server. Samba 3.6 SMB/CIFS server
# 3.luci # LuCI -->3.Applications ---><*>luci-app-samba. Network Shares - Samba SMB/CIFS module
# (2)编译后设置samba # vim /etc/config/samba # 改成下面这样: # config samba # option 'name' 'OpenWrt' # option 'workgroup' 'WORKGROUP' # option 'description' 'OpenWrt' # option 'homes' '1' # # config sambashare # option 'browseable' 'yes' # option 'name' 'share' # option 'path' '/root/samba_share' # option 'users' 'root' # option 'writable' 'yes' # option 'read_only' 'no' # option 'guest_ok' 'no' # option 'create_mask' '0755' # option 'dir_mask' '0755'
# vim /etc/samba/smb.conf.template # 一定要注释这一行。因为下面设置的是root用户,如果不注释,没法用root登录到samba # [global] # ... ... # # invalid users = root # ... ...
# vim ${HOME}/openwrt/staging_dir/target-mipsel_24kc_musl/root-ramips/etc/config/samba 修改这个文件的配置,然后编译。下同
# (3)设置账号密码 # mkdir -vp /root/samba_share /root/samba_mount # smbpasswd -a root #输入密码:123456
# (4)openwrt挂载到ubuntu的samba # option 'name' 'share',所以是192.168.100.156/share 对应的路径是/root/samba_share # sudo mount -t cifs //192.168.100.156/share /root/samba_mount -o user=root,password=123456,vers=1.0 # 问题: # [10478.224569] No dialect specified on mount. Default has changed to a more secure dialect, SMB2.1 or later (e.g. SMB3), from CIFS (SMB1). To use the less secure SMB1 dialect to access old servers which do not support SMB3 (or SMB2.1) specify vers=1.0 on mount. # 解决: 编译的时候选择samba36, # 添加vers=1.0
# (5)ubuntu和windows挂载到openwrt的方法和ubuntu的samba一样
# 四、openwrt安装dlna # (1)编译选择 # Multimedia --><*> minidlna. UPnP A/V & DLNA Media Server # LuCI -->3.Applications ---><*>luci-app-minidlna. LuCI Support for miniDLNA
# (2)配置文件 # vim /etc/config/minidlna # config minidlna 'config' # option enabled '1' #这个改为1,其他保留原来安装好的默认值,就这样访问:http://192.168.100.138:8200/。如果是使用opkg install minidlna,那么默认是0。如果编译安装,那么默认是1 # option user 'minidlna' # option port '8200' # option interface 'br-lan' # option friendly_name 'OpenWrt DLNA Server' # option db_dir '/var/run/minidlna' # option inotify '1' # option enable_tivo '0' # option wide_links '0' # option strict_dlna '0' # option notify_interval '900' # option serial '12345678' # option model_number '1' # option root_container '.' # list media_dir '/mnt/usb_file' #修改这个路径 # option album_art_names 'Cover.jpg/cover.jpg/AlbumArtSmall.jpg/albumartsmall.jpg/AlbumAr # option uuid 'efc78012-83b6-4145-a192-63bf58783849'
# 四、openwrt安装usb驱动 # https://blog.csdn.net/qianguozheng/article/details/41245425 # OpenWrt 添加usb驱动及相关脚本
# (1)添加内核相关支持 # 编译openwrt支持USB自动mount功能 # make menuconfig # 1). 添加USB相关支持 # Kernel modules —> USB Support —> <*> kmod-usb-core. # Kernel modules —> USB Support —> <*> kmod-usb-ohci. #安装usb ohci控制器驱动 # Kernel modules —> USB Support —> <*> kmod-usb-uhci. #UHCI USB控制器 # Kernel modules —> USB Support —> <*> kmod-usb-storage. #安装usb存储设备驱动 # Kernel modules —> USB Support —> <*> kmod-usb-storage-extras. # Kernel modules —> USB Support —> <*> kmod-usb2. #安装usb2.0 # Kernel modules —> USB Support —> <*> kmod-usb3. # 2). 添加SCSI支持 # Kernel modules —> Block Devices —> <*>kmod-scsi-core # 3). 添加USB挂载 # Base system —> <*>block-mount # 4). 添加自动挂载工具 # Utilities —> Filesystem —> <*> badblocks # 选了上面的,自动选择了e2fsprogs。有了这个,就可以执行:mkfs.ext4 /dev/sda4 格式化U盘 # 5). 添加文件系统支持 # Kernel modules —> Filesystems —> <*> kmod-fs-ext4 # Kernel modules —> Filesystems —> <*> kmod-fs-vfat #挂载FAT # Kernel modules —> Filesystems —> <*> kmod-fs-ntfs #ntfs内核驱动 # 6). 添加UTF8编码,CP437编码,ISO8859-1编码,cp936编码 # Kernel modules —> Native Language Support —> <*> kmod-nls-cp437 # Kernel modules —> Native Language Support —> <*> kmod-nls-iso8859-1 # Kernel modules —> Native Language Support —> <*> kmod-nls-utf8 # Kernel modules —> Native Language Support —> <*> kmod-nls-cp936...... Codepage 936 (Simplified Chinese) # Kernel modules —> Native Language Support —> <*> kmod-nls-cp950...... Codepage 950 (Traditional Chinese) # Kernel modules —> Native Language Support —> <*> kmod-nls-iso8859-2...... ISO 8859-2 (Latin 2; Central European Languages) # Utilities ---> disc ---> <*> fdisk.................................... manipulate disk partition table #硬盘分区管理工具 # Utilities ---> <*> usbutils................................... USB devices listing utilities #安装了这个后可以用 lsusb 取消这个,会出错!
# 7) # Utilities --->Filesystem --><*> ntfs-3g. Stable Read/Write NTFS Driver # Utilities ---><*> mount-utils. related (u)mount utilities
# 下面两个没找到,不知道有没有 # opkg install hotplug #热插拔,但是实际上热插拔可以用的。 # opkg install mount.ntfs-3g --nodeps #挂载ntfs助手 没法安装 # 另外选了: # Utilities ---> Shells ---> <*> bash. The GNU Bourne Again Shell # Editors ---> <*> vim-full. Vi IMproved - enhanced vi editor (Normal) # 如果选择手动安装,又下面的问题: # 错误: # Collected errors: # * satisfy_dependencies_for: Cannot satisfy the following dependencies for kmod-usb-core: # * kernel (= 5.4.52-1-2c2a29f33dbfa5b2cb8147e6db800d0d) * # 解决: --nodeps # 错误: # Error loading shared library libmount.so.1: No such file or directory (needed by /usr/bin/mount) # Error relocating /usr/lib/libblkid.so.1: secure_getenv: symbol not found # 解决:用重新编译,不用opkg install来安装
# (2)手动挂载 # U盘格式化成ntfs,挂载会出错,用电脑,把U盘格式化成vfat,才能挂载成功。 # mount -t vfat /dev/sda4 /mnt
# (3)开机自动挂载 # 1) # mkdir /mnt/usb_file # 2) # vim /etc/config/fstab # config 'mount' # option target '/mnt/usb_file' # option device /dev/sda4 # option fstype vfat # option options rw,sync # # option uuid 'C6F5-4925' # option enabled '1'
# 要注意的是:如果是ntfs,那么使用这个方法不行,只能使用热插拔脚本的方法。
# 3) # 插入U盘,重启就可以了。执行下面不成功。 # /etc/init.d/fstab enable # /etc/init.d/fstab restart
# (4)热插拔支持 # 挂载vfat的脚本 # 自动挂载脚本,在/etc/hotplug.d/block/创建一个30-usbmount的文件, # #!/bin/sh # case "$ACTION" in # add) # for i in $(ls /dev/ | grep 'sd[a-z][1-9]') # do # mkdir -p /mnt/$i # mount -o iocharset=utf8,rw /dev/$i /mnt/$i # if [ "$?" -ne 0 ];then # mount -o rw /dev/$i /mnt/$i # fi # done # ;; # remove) # MOUNT=`mount | grep -o '/mnt/sd[a-z][1-9]'` # for i in $MOUNT # do # umount $i # done # ;; # esac # 上面实测,没问题。
# 挂载ntfs的脚本 # #!/bin/sh # # Copyright (C) 2009 OpenWrt.org (C) 2010 OpenWrt.org.cn # blkdev=`dirname $DEVPATH` # if [ `basename $blkdev` != "block" ]; then # device=`basename $DEVPATH` # case "$ACTION" in # add) # mkdir -p /mnt/$device # # vfat & ntfs-3g check # if [ `which fdisk` ]; then # isntfs=`fdisk -l | grep $device | grep NTFS` # isvfat=`fdisk -l | grep $device | grep FAT` # isfuse=`lsmod | grep fuse` # isntfs3g=`which ntfs-3g` # else # isntfs="" # isvfat="" # fi # # mount with ntfs-3g if possible, else with default mount # if [ "$isntfs" -a "$isfuse" -a "$isntfs3g" ]; then # ntfs-3g -o nls=utf8 /dev/$device /mnt/$device # elif [ "$isvfat" ]; then # mount -t vfat -o iocharset=utf8,rw,sync,umask=0000,dmask=0000,fmask=0000 /dev/$device /mnt/$device # else # mount /dev/$device /mnt/$device # fi # if [ -f /dev/${device}/swapfile ]; then # mkswap /dev/${device}/swapfile # swapon /dev/${device}/swapfile # fi # ;; # remove) # if [ -f /dev/${device}/swapfile ]; then # swapoff /dev/${device}/swapfile # fi # umount /dev/$device # ;; # esac # fi
# 下面没用 # (3)安装vlc # sudo add-apt-repository ppa:n-muench/vlc # sudo apt-get update # sudo apt-get install vlc
# 第一次编译可以参考根目录下面的README文档 # cd openwrt # #更新feeds.conf中的种子包 # ./scripts/feeds update -a # #安装软链接到package/feeds/,这样make menuconfig才能进行相关配置 # ./scripts/feeds install -a
# 没有kmod-fs-exfat 把电影拷贝到U盘,有一些电影不行。
