openwrt samba dlna

#!/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'              #IP后面就跟着这个
    #     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一样
    # windows-->打开资源管理器-->点击网络-->输入:\\192.168.8.1-->回车
    # 如果出现输入IP后,能打开,但是双击,然后输入密码后,没法进入文件,那么直接把开发板接到电脑上,开发板作为路由器。这样试试!!


    # 四、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'    #修改这个路径  看下面,这个文件夹挂载到外部的U盘,自己创建
    #         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
    #                 <*>busybox -->Linux System Utilities -->[*] mke2fs
    #                                                         [*] mkfs.vfat
    
    # 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   取消这个,会出错!
    # 出现这个错误:https://downloads.openwrt.org/sources/usb.ids
    #               Hash of the downloaded file does not math (file:

    # 7)
    # Utilities  --->Filesystem  --><*> ntfs-3g. Stable Read/Write NTFS Driver
    #                               <*> ntfs-3g-utils  ntfs-3g utilities
    # Utilities  ---><*> mount-utils. related (u)mount utilities

    # 下面两个没找到,不知道有没有
    # opkg install hotplug                   #热插拔,但是实际上热插拔可以用的。
    # opkg install mount.ntfs-3g    --nodeps #挂载ntfs助手                 没法安装

    # 如果选择手动安装,又下面的问题:
    # 错误:
    # 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'

    # 要注意的是:
    # 1、如果同时/etc/hotplug.d/block/10-usbmount把/dev/sda1自动挂载到/mnt/sda1,/etc/config/fstab把/dev/sda1挂载到/mnt/usb_file,那么最后按照10-usbmount那样,把/dev/sda1挂载到/mnt/sda1
    #    因此如果/dev/sda1一直插板上,那么应该去掉10-usbmount,保留fstab的配置。
    # 2、如果/etc/config/fstab把/dev/sda1挂载到/mnt/usb_file,/dev/sda1是ntfs格式,那么文件如下:
    # vim /etc/config/fstab
    # config 'mount'
    #         option  target  '/mnt/usb_file'
    #         option  device /dev/sda1
    #         option  fstype ntfs
    #         option  options rw,sync,nls=utf8
    #         option  uuid    'C6F5-4925'
    #         option  enabled '1'
    # 
    #    (1)注意:option  fstype ntfs
    #    (2)注意:option  options rw,sync,nls=utf8
    #     如果没有nls=utf8,那么会出现下面的错误:
    #     ntfs_ucstonls(): Unicode name contains characters that cannot be converted to character set default.  You might want to try to use the mount option nls=utf8.
    # 3、使用/etc/config/fstab挂载,/mnt/usb_file没法写,只能读
    #    终端执行:umount /mnt/usb_file
    #              mount -t ntfs-3g /dev/sda1 /mnt/usb_file
    #              这样/mnt/usb_file就能写
    #    因此解决方法就是不使用/etc/config/fstab挂载(注释掉里面的挂载/mnt/usb_file配置),然后使用/etc/hotplug.d/block/10-usbmount脚本挂载

    # 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的脚本
    # 自动挂载脚本,在/etc/hotplug.d/block/创建一个10-usbmount的文件,
    # #!/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


 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值