V1.7.6 新增删除 Samba 密码; 优化提示
This commit is contained in:
parent
6c1d462754
commit
ec1d368ef4
|
@ -3,7 +3,7 @@
|
||||||
# AutoBuild_Tools for Openwrt
|
# AutoBuild_Tools for Openwrt
|
||||||
# Dependences: bash wget curl block-mount e2fsprogs smartmontools
|
# Dependences: bash wget curl block-mount e2fsprogs smartmontools
|
||||||
|
|
||||||
Version=V1.7.5
|
Version=V1.7.6
|
||||||
|
|
||||||
ECHO() {
|
ECHO() {
|
||||||
case $1 in
|
case $1 in
|
||||||
|
@ -157,7 +157,7 @@ ${White}q. 退出
|
||||||
8)
|
8)
|
||||||
Sysinfo
|
Sysinfo
|
||||||
clear
|
clear
|
||||||
ECHO y "IP MAC"
|
ECHO y "IP 地址 MAC 地址"
|
||||||
grep "br-lan" /proc/net/arp | grep "0x2" | grep -v "0x0" | grep "$(echo ${IPv4} | egrep -o "[0-9]+\.[0-9]+\.[0-9]+")" | awk '{print $1"\t\t"$4}'
|
grep "br-lan" /proc/net/arp | grep "0x2" | grep -v "0x0" | grep "$(echo ${IPv4} | egrep -o "[0-9]+\.[0-9]+\.[0-9]+")" | awk '{print $1"\t\t"$4}'
|
||||||
ENTER
|
ENTER
|
||||||
;;
|
;;
|
||||||
|
@ -219,7 +219,7 @@ USB_Info() {
|
||||||
rm -f ${Block_Info} ${Logic_Disk_List} ${Disk_Processed_List} ${Phy_Disk_List}
|
rm -f ${Block_Info} ${Logic_Disk_List} ${Disk_Processed_List} ${Phy_Disk_List}
|
||||||
touch ${Disk_Processed_List}
|
touch ${Disk_Processed_List}
|
||||||
block mount
|
block mount
|
||||||
block info | grep -v "mtdblock" | grep "sd[a-z][0-9]" > ${Block_Info}
|
block info | grep -v "mtdblock" | egrep "sd[a-z][0-9]|mmcblk" > ${Block_Info}
|
||||||
[[ -s ${Block_Info} ]] && {
|
[[ -s ${Block_Info} ]] && {
|
||||||
cat ${Block_Info} | awk -F ':' '/sd/{print $1}' > ${Logic_Disk_List}
|
cat ${Block_Info} | awk -F ':' '/sd/{print $1}' > ${Logic_Disk_List}
|
||||||
for Disk_Name in $(cat ${Logic_Disk_List})
|
for Disk_Name in $(cat ${Logic_Disk_List})
|
||||||
|
@ -229,24 +229,25 @@ USB_Info() {
|
||||||
[[ -z ${Logic_Mount} ]] && Logic_Mount="$(df | grep "${Disk_Name}" | awk '{print $6}' | awk 'NR==1')"
|
[[ -z ${Logic_Mount} ]] && Logic_Mount="$(df | grep "${Disk_Name}" | awk '{print $6}' | awk 'NR==1')"
|
||||||
Logic_Format="$(grep "${Disk_Name}" ${Block_Info} | egrep -o 'TYPE="[0-9a-zA-Z].+' | awk -F '["]' '/TYPE/{print $2}')"
|
Logic_Format="$(grep "${Disk_Name}" ${Block_Info} | egrep -o 'TYPE="[0-9a-zA-Z].+' | awk -F '["]' '/TYPE/{print $2}')"
|
||||||
Logic_Available="$(df -h | grep "${Disk_Name}" | awk '{print $4}' | awk 'NR==1')"
|
Logic_Available="$(df -h | grep "${Disk_Name}" | awk '{print $4}' | awk 'NR==1')"
|
||||||
|
[[ -z ${UUID} ]] && UUID='-'
|
||||||
[[ -z ${Logic_Format} ]] && Logic_Format='-'
|
[[ -z ${Logic_Format} ]] && Logic_Format='-'
|
||||||
[[ -z ${Logic_Mount} ]] && Logic_Mount='-'
|
[[ -z ${Logic_Mount} ]] && Logic_Mount='-'
|
||||||
[[ -z ${Logic_Available} ]] && Logic_Available='-'
|
[[ -z ${Logic_Available} ]] && Logic_Available='-'
|
||||||
echo "${Disk_Name} ${UUID} ${Logic_Format} ${Logic_Mount} ${Logic_Available}" >> ${Disk_Processed_List}
|
echo "${Disk_Name} ${UUID} ${Logic_Format} ${Logic_Mount} ${Logic_Available}" >> ${Disk_Processed_List}
|
||||||
done
|
done
|
||||||
grep -o "/dev/sd[a-z]" ${Logic_Disk_List} | sort | uniq > ${Phy_Disk_List}
|
egrep -o "/dev/sd[a-z]|mmcblk" ${Logic_Disk_List} | sort | uniq > ${Phy_Disk_List}
|
||||||
}
|
}
|
||||||
echo -ne "\r \r"
|
echo -ne "\r \r"
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
AutoExpand_Core() {
|
AutoExpand_Core() {
|
||||||
ECHO r "\n警告: 操作开始后请不要中断任务或进行其他操作,否则可能导致设备数据丢失!"
|
ECHO r "\n警告: 操作开始后请不要中断任务或进行其他操作,否则可能导致设备无法开机"
|
||||||
ECHO r "固件更新将改变分区表,从而导致扩容失效,并且当前硬盘数据将会丢失!"
|
ECHO r " 固件更新将改变分区表,从而导致扩容失效,当前硬盘上的数据可能会丢失"
|
||||||
ECHO r "\n本操作将把设备 '$1' 格式化为 ext4 格式,请提前做好数据备份工作!"
|
echo -ne "\n${Yellow}本操作将把设备 '$1' 格式化为 ext4 格式,${White}"
|
||||||
read -p "是否执行格式化操作?[Y/n]:" Choose
|
read -p "是否确认执行格式化操作?[Y/n]:" Choose
|
||||||
[[ ${Choose} == [Yesyes] ]] && {
|
[[ ${Choose} == [Yesyes] ]] && {
|
||||||
ECHO y "\n开始运行脚本 ..."
|
ECHO y "\n开始运行一键挂载脚本 ..."
|
||||||
sleep 2
|
sleep 2
|
||||||
} || return 0
|
} || return 0
|
||||||
echo "禁用自动挂载 ..."
|
echo "禁用自动挂载 ..."
|
||||||
|
@ -281,7 +282,7 @@ AutoExpand_Core() {
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
mount --bind / /tmp/introot || {
|
mount --bind / /tmp/introot || {
|
||||||
ECHO r "挂载 '/' 到 '/tmp/introot' 失败!"
|
ECHO r "绑定 '/' 到 '/tmp/introot' 失败!"
|
||||||
exit 1
|
exit 1
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -308,13 +309,12 @@ config mount
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
uci commit fstab
|
uci commit fstab
|
||||||
ECHO y "\n运行结束,外接设备 '$1' 已挂载到系统分区!\n"
|
ECHO y "\n运行结束,外接设备 '$1' 已挂载为系统根目录 '/'\n"
|
||||||
read -p "操作需要重启生效,是否立即重启?[Y/n]:" Choose
|
read -p "操作需要重启生效,是否立即重启?[Y/n]:" Choose
|
||||||
[[ ${Choose} == [Yesyes] ]] && {
|
[[ ${Choose} == [Yesyes] ]] && {
|
||||||
ECHO g "\n正在重启设备,请耐心等待 ..."
|
ECHO g "\n正在重启设备,请耐心等待 ..."
|
||||||
sync
|
sync
|
||||||
reboot
|
reboot
|
||||||
exit
|
|
||||||
} || exit
|
} || exit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -328,9 +328,10 @@ Samba_UI() {
|
||||||
clear
|
clear
|
||||||
ECHO x "Samba 工具箱\n"
|
ECHO x "Samba 工具箱\n"
|
||||||
echo "1. 自动生成 Samba 挂载点"
|
echo "1. 自动生成 Samba 挂载点"
|
||||||
echo "2. 删除所有 Samba 挂载点"
|
echo "2. 删除已有挂载点"
|
||||||
echo "3. $([[ ${autoshare_Mode} == 1 ]] && echo 关闭 || echo 开启) Samba 自动共享"
|
echo "3. $([[ ${autoshare_Mode} == 1 ]] && ECHO r 关闭 || ECHO y 开启) Samba 自动共享"
|
||||||
echo "4. 设置 Samba 访问密码 $([ -s /etc/samba/smbpasswd ] && echo -e "${Yellow}[已设置]${White}")"
|
echo "4. 设置 Samba 访问密码 $([ -s /etc/samba/smbpasswd ] && ECHO y "[已设置]" || ECHO r "[未设置]")"
|
||||||
|
[ -s /etc/samba/smbpasswd ] && echo "5. 删除 Samba 密码"
|
||||||
echo -e "\nq. 返回\n"
|
echo -e "\nq. 返回\n"
|
||||||
read -p "请从上方选项中选择一个操作:" Choose
|
read -p "请从上方选项中选择一个操作:" Choose
|
||||||
case ${Choose} in
|
case ${Choose} in
|
||||||
|
@ -390,15 +391,23 @@ EOF
|
||||||
;;
|
;;
|
||||||
4)
|
4)
|
||||||
sed -i '/invalid users/d' /etc/samba/smb.conf.template >/dev/null 2>&1
|
sed -i '/invalid users/d' /etc/samba/smb.conf.template >/dev/null 2>&1
|
||||||
ECHO y "\n注意: 请连续输入两次密码,输入的密码不会显示,输入后回车即可!"
|
ECHO y "\n注意: 将为 root 用户设置密码,同时自动允许 root 用户进行访问,
|
||||||
|
请连续输入两次相同的密码,输入的内容不会显示,完成后回车即可!\n"
|
||||||
smbpasswd -a root
|
smbpasswd -a root
|
||||||
[[ $? == 0 ]] && {
|
[[ $? == 0 ]] && {
|
||||||
ECHO y "\nSamba 访问密码设置成功!"
|
ECHO y "\n已为 root 用户设置 Samba 访问密码!"
|
||||||
/etc/init.d/samba restart
|
/etc/init.d/samba restart
|
||||||
} || {
|
} || {
|
||||||
ECHO r "\nSamba 访问密码设置失败!"
|
ECHO r "\nSamba 访问密码设置失败!"
|
||||||
}
|
}
|
||||||
;;
|
;;
|
||||||
|
5)
|
||||||
|
if [ -s /etc/samba/smbpasswd ];then
|
||||||
|
smbpasswd -x root
|
||||||
|
ECHO y "\n已删除 Samba 访问密码!"
|
||||||
|
/etc/init.d/samba restart
|
||||||
|
fi
|
||||||
|
;;
|
||||||
q)
|
q)
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
|
@ -499,7 +508,7 @@ SmartInfo_UI() {
|
||||||
done
|
done
|
||||||
ENTER
|
ENTER
|
||||||
} || {
|
} || {
|
||||||
ECHO r "未检测到任何外接设备,请检查接口或插入 USB 设备!"
|
ECHO r "未检测到任何外接设备,请检查 USB 接口可用性或插入更多 USB 设备!"
|
||||||
sleep 2
|
sleep 2
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue