up luci-app-partexp 1.1.0版,取消第三方依赖,修复挂载问题。

This commit is contained in:
Pdboy Sir 2024-03-15 16:53:29 +08:00 committed by GitHub
parent 0de3d3b2bc
commit 32e27852ff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 383 additions and 224 deletions

View File

@ -7,8 +7,8 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-partexp PKG_NAME:=luci-app-partexp
PKG_VERSION:=0.1.9 PKG_VERSION:=1.1.0
PKG_RELEASE:=20221201 PKG_RELEASE:=20240314
PKG_LICENSE:=Apache-2.0 PKG_LICENSE:=Apache-2.0
PKG_MAINTAINER:=Sirpdboy <herboy2008@gmail.com> PKG_MAINTAINER:=Sirpdboy <herboy2008@gmail.com>

View File

@ -2,79 +2,48 @@
LuCI - Lua Configuration Partition Expansion LuCI - Lua Configuration Partition Expansion
Copyright (C) 2022 sirpdboy <herboy2008@gmail.com> https://github.com/sirpdboy/partexp Copyright (C) 2022 sirpdboy <herboy2008@gmail.com> https://github.com/sirpdboy/partexp
]]-- ]]--
require "luci.util"
local fs = require "nixio.fs"
local http = require "luci.http"
local uci = require"luci.model.uci".cursor()
local name = 'partexp' local name = 'partexp'
module("luci.controller.partexp", package.seeall) module("luci.controller.partexp", package.seeall)
function index() function index()
entry({"admin","system","partexp"},alias("admin", "system", "partexp", "global"),_("Partition Expansion"), 54) local e = entry({"admin","system","partexp"},alias("admin", "system", "partexp", "global"),_("Partition Expansion"), 54)
e.dependent = false
e.acl_depends = { "luci-app-partexp" }
entry({"admin", "system", "partexp", "global"}, cbi('partexp/global', {hideapplybtn = true, hidesavebtn = true, hideresetbtn = true}), _('Partition Expansion'), 10).leaf = true entry({"admin", "system", "partexp", "global"}, cbi('partexp/global', {hideapplybtn = true, hidesavebtn = true, hideresetbtn = true}), _('Partition Expansion'), 10).leaf = true
entry({"admin", "system", "partexp","partexprun"}, call("partexprun")).leaf = true entry({"admin", "system", "partexp","partexprun"}, call("partexprun"))
-- entry({"admin", "system", "partexp", "realtime_log"}, call("get_log")) entry({"admin", "system", "partexp", "check"}, call("act_check"))
end
function act_check()
http.prepare_content("text/plain; charset=utf-8")
local f=io.open("/etc/partexp/partexp.log", "r+")
local fdp=fs.readfile("/etc/partexp/lucilogpos") or 0
f:seek("set",fdp)
local a=f:read(2048000) or ""
fdp=f:seek()
fs.writefile("/etc/partexp/lucilogpos",tostring(fdp))
f:close()
http.write(a)
end end
function get_log()
local e = {}
e.running = luci.sys.call("busybox ps -w | grep partexp | grep -v grep >/dev/null") == 0
e.log = fs.readfile("/etc/partexp/partexp.log") or ""
luci.http.prepare_content("application/json")
luci.http.write_json(e)
end
function partexprun() function partexprun()
local uci = luci.model.uci.cursor() local kconfig = http.formvalue('kconfig')
local keep_config = luci.http.formvalue('keep_config') local aformat = http.formvalue('aformat')
local auto_format = luci.http.formvalue('auto_format') local targetf = http.formvalue('targetf')
local target_function = luci.http.formvalue('target_function') local targetd = http.formvalue('targetd')
local target_disk = luci.http.formvalue('target_disk') uci:set(name, 'global', 'target_disk', targetd)
--uci:delete(name, '@global[0]', global) uci:set(name, 'global', 'target_function', targetf)
uci:set(name, '@global[0]', 'target_disk', target_disk) uci:set(name, 'global', 'auto_format', aformat)
uci:set(name, '@global[0]', 'target_function', target_function) uci:set(name, 'global', 'keep_config', kconfig)
uci:set(name, '@global[0]', 'auto_format', auto_format)
uci:set(name, '@global[0]', 'keep_config', keep_config)
uci:commit(name) uci:commit(name)
-- e = nixio.exec("/bin/sh", "-c" ,"/etc/init.d/partexp autopart") fs.writefile("/etc/partexp/lucilogpos","0")
e = luci.sys.exec('/etc/init.d/partexp autopart') http.prepare_content("application/json")
http.write('')
luci.http.prepare_content('application/json') luci.sys.exec("/etc/init.d/partexp autopart > /etc/partexp/partexp.log 2>&1 &")
luci.http.write_json(e)
end end
function outexec(cmd)
luci.http.prepare_content("text/plain")
local util = io.popen(cmd)
if util then
while true do
local ln = util:read("*l")
if not ln then break end
luci.http.write(ln)
luci.http.write("\n")
end
util:close()
end
end
function fork_exec(command)
local pid = nixio.fork()
if pid > 0 then
return
elseif pid == 0 then
-- change to root dir
nixio.chdir("/")
-- patch stdin, out, err to /dev/null
local null = nixio.open("/dev/null", "w+")
if null then
nixio.dup(null, nixio.stderr)
nixio.dup(null, nixio.stdout)
nixio.dup(null, nixio.stdin)
if null:fileno() > 2 then
null:close()
end
end
-- replace with target command
nixio.exec("/bin/sh", "-c", command)
end
end

View File

@ -40,8 +40,10 @@ t.anonymous=true
e=t:option(ListValue,"target_function", translate("Select function"),translate("Select the function to be performed")) e=t:option(ListValue,"target_function", translate("Select function"),translate("Select the function to be performed"))
e:value("/overlay", translate("Expand application space overlay (/overlay)")) e:value("/overlay", translate("Expand application space overlay (/overlay)"))
-- e:value("/", translate("Use as root filesystem (/)")) -- e:value("/", translate("Use as root filesystem (/)"))
-- e:value("/lnoverlay", translate("Soft chain partition expansion(/overlay)"))
e:value("/opt", translate("Used as Docker data disk (/opt)")) e:value("/opt", translate("Used as Docker data disk (/opt)"))
e:value("/dev", translate("Normal mount and use by device name(/dev/x1)")) e:value("/dev", translate("Normal mount and use by device name(/dev/x1)"))
e.default="/opt"
e=t:option(ListValue,"target_disk", translate("Destination hard disk"),translate("Select the hard disk device to operate")) e=t:option(ListValue,"target_disk", translate("Destination hard disk"),translate("Select the hard disk device to operate"))
for i, d in ipairs(devices) do for i, d in ipairs(devices) do
@ -52,32 +54,18 @@ for i, d in ipairs(devices) do
end end
end end
o=t:option(Flag,"keep_config",translate("Keep configuration"),translate("Tick means to retain the settings")) e=t:option(Flag,"keep_config",translate("Keep configuration"),translate("Tick means to retain the settings"))
o:depends("target_function", "/overlay") e:depends("target_function", "/overlay")
o.default=0 e.default=0
o=t:option(Flag,'auto_format', translate('Format before use'),translate("Ticking indicates formatting")) e=t:option(Flag,'auto_format', translate('Format before use'),translate("Ticking indicates formatting"))
o:depends("target_function", "/opt") e:depends("target_function", "/opt")
o:depends("target_function", "/dev") e:depends("target_function", "/dev")
o.default=0 -- e:depends("target_function", "/lnoverlay")
e.default=0
o=t:option(DummyValue, '', '') e=t:option(Button, "restart", translate("Perform operation"))
o.rawhtml = true e.inputtitle=translate("Click to execute")
o.template ='partexp' e.template ='partexp'
e=t:option(TextValue,"log")
e.rows=15
e.wrap="on"
e.readonly=true
e.cfgvalue=function(t,t)
return fs.readfile("/etc/partexp/partexp.log")or""
end
e.write=function(e,e,e)
end
-- e =t:option(DummyValue, '', '')
-- e.rawhtml = true
-- e.template = 'partexplog'
return m return m

View File

@ -1,106 +1,128 @@
<%# <%#
Copyright (C) 2022 sirpdboy <herboy2008@gmail.com> https://github.com/sirpdboy/partexp Copyright (C) 2022-2024 sirpdboy <herboy2008@gmail.com> https://github.com/sirpdboy/partexp
-%> -%>
<%
local fs = require "nixio.fs"
%>
<%+cbi/valueheader%> <%+cbi/valueheader%>
<%local fs=require"nixio.fs"%>
<script src="/luci-static/vssr/jquery.min.js"></script> <input type="button" class="btn cbi-button cbi-button-apply" id="apply_run_button" value="<%:Click to execute%>" onclick=" return apply_run(this) "/>
<label class="cbi-value-title"><%= translate("Select the function to be performed") %></label> <div id="logview" style="display:none">
<div class="cbi-value-field"> <input type="checkbox" id="reversetag" value="reverse" onclick=" return reverselog()" style="vertical-align:middle;height: auto;"><%:reverse%></input>
<input class="cbi-button cbi-button-reload" id="go_partexprun" type="button" value="<%= translate("Perform operation") %>"> <textarea id="cbid.logview.1.conf" class="cbi-input-textarea" style="width: 100%;display:block;" data-update="change" rows="20" cols="80" readonly="readonly" > </textarea>
</div> </div>
<fieldset class="cbi-section" style="display:none"> <script type="text/javascript">//<![CDATA[
<legend id="partexprun-legend">
<%:Collecting data...%>
</legend>
<span id="partexprun-output"></span>
</fieldset>
<script type="text/javascript"> const PARTEXP_RUN_URL = '<%=luci.dispatcher.build_url("admin", "system", "partexp","partexprun")%>';
const PARTEXP_RUN_URL = '<%=luci.dispatcher.build_url("admin", "system", "partexp","partexprun")%>'; const PARTEXP_CHECK = '<%=luci.dispatcher.build_url("admin", "system", "partexp","check")%>';
const PARTEXP_URL = '<%=luci.dispatcher.build_url("admin", "system", "partexp","global")%>';
var legend = document.getElementById('partexprun-legend'); var checkbtn = document.getElementById('apply_run_button');
var output = document.getElementById('partexprun-output');
var islogreverse = false;
$(document).ready(function(){ function reverselog(){
// alert("hello"); var lv = document.getElementById('cbid.logview.1.conf');
function go_run() { lv.innerHTML=lv.innerHTML.split('\n').reverse().join('\n')
legend.style.display = 'none'; if (islogreverse){
output.innerHTML ='</p><%:After operation, restart the machine, please wait...%></p>'; islogreverse=false;
setTimeout(() => { window.location = PARTEXP_URL }, 6000); }else{
} islogreverse=true;
function go_err() {
legend.style.display = 'none';
output.innerHTML ='</p><%:Please delete the partition or share and try again%></p>';
setTimeout(() => { window.location = PARTEXP_URL }, 6000);
}
$("#go_partexprun").click(function () {
if (confirm('<%:Restart the device to take effect. Confirm whether to continue?%>'))
{
prefix_array = $("#cbi-partexp .cbi-section-node").attr("id").split("-");
prefix_array[0] = "cbid";
prefix = prefix_array.join(".");
output.innerHTML =
'<img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" /> ' +
'<%:Operation in progress, please wait...%>'
;
legend.parentNode.style.display = 'block';
legend.style.display = 'inline';
var target_function = $("[name='" + prefix + ".target_function']").val();
if ($("[name='" + prefix + ".keep_config']").is(":checked")) {
var keep_config = "1";
} else {
var keep_config = "0";
}
var target_disk = $("[name='" + prefix + ".target_disk']").val();
if ($("[name='" + prefix + ".auto_format']").is(":checked")) {
var auto_format = "1";
} else {
var auto_format = "0";
}
var data = {
keep_config: keep_config,
target_disk: target_disk,
auto_format: auto_format,
target_function: target_function
}
$.ajax({
type: "post",
url: PARTEXP_RUN_URL,
dataType: "json",
data: data,
success: function (d) {
if (d == 2) {
legend.style.display = 'none';
output.innerHTML ='</p><%:After operation, restart the machine, please wait...%></p>';
} else {
legend.style.display = 'none';
output.innerHTML ='</p> <%:Operation execution complete%></p>';
}
setTimeout(() => { window.location = PARTEXP_URL }, 5000);
}
});
return false;
} }
}); return
}); }
function apply_run(btn){
var sid='global'
var opt={
base:"cbid.partexp."+sid,
get:function(opt){
var id=this.base+'.'+opt;
var obj=document.getElementsByName(id)[0] || document.getElementsByClassName(id)[0] || document.getElementById(id)
if (obj){
return obj;
}else{
return null;
}
},
getlist:function(opt){
var id=this.base+'.'+opt;
var objs=document.getElementsByName(id) || document.getElementsByClassName(id);
var ret=[];
if (objs){
for (var i=0;i < objs.length;i++){
ret[i]=objs[i].value;
}
}else{
alert("<%:Fatal on get option,please help in debug%>:"+opt);
}
return ret;
},
query:function(param,src,tval="1",fval="0"){
var ret="&"+param+"=";
var obj=this.get(src);
if (obj){
if (obj.type=="checkbox"){
return ret+(obj.checked==true ? tval:fval);
}else{
return ret+encodeURIComponent(obj.value);
}
}
return ''
}
}
btn.value='<%:Waiting,(executing)...%>';
btn.disabled=true;
var targetf=opt.get("target_function").value;
var targetd=opt.get("target_disk").value;
if (opt.get("auto_format"))
var aformat = opt.get("auto_format").checked ? 1 : 0;
else
var aformat = 0;
if (opt.get("keep_config"))
var kconfig = opt.get("keep_config").checked ? 1 : 0;
else
var kconfig = 0;
console.log(kconfig);
XHR.get('<%=url([[admin]], [[system]], [[partexp]], [[partexprun]])%>',{
targetf: targetf,
kconfig: kconfig,
targetd: targetd,
aformat: aformat
},function(x){});
poll_check();
return
}
function poll_check(){
var tag = document.getElementById('logview');
tag.style.display="block"
XHR.poll(3, '<%=url([[admin]], [[system]], [[partexp]], [[check]])%>', null,
function(x, data) {
var lv = document.getElementById('cbid.logview.1.conf');
if (x.responseText && lv) {
if (x.responseText=="\u0000"){
for(j = 0,len=this.XHR._q.length; j < len; j++) {
if (this.XHR._q[j].url == '<%=url([[admin]], [[system]], [[partexp]], [[check]])%>'){
this.XHR._q.splice(j,1);
checkbtn.disabled = false;
checkbtn.value = '<%:Click to execute%>';
break;
}
}
return
}
if (islogreverse){
lv.innerHTML = x.responseText.split('\n').reverse().join('\n')+lv.innerHTML;
}else{
lv.innerHTML += x.responseText;
}
}
}
);}
//]]>
</script> </script>
<%+cbi/valuefooter%> <%+cbi/valuefooter%>

View File

@ -0,0 +1,76 @@
msgid ""
msgstr ""
"Copyright (C) 2022-2024 sirpdboy herboy2008@gmail.com https://github.com/sirpdboy/luci-app-partexp"
"This is free software, licensed under the GNU General Public License v3."
msgid "Partition Expansion"
msgstr "分区扩容"
msgid "One click partition expansion mounting tool"
msgstr "一键分区扩容挂载工具"
msgid "Automatically format and mount the target device partition. If there are multiple partitions, it is recommended to manually delete all partitions before using this tool.<br/>For specific usage, see:"
msgstr "自动对目标设备分区格式化挂载,如果有多分区建议手动删除所有分区再使用本工具.<br/>使用说明见:"
msgid "Waiting,(executing)..."
msgstr "稍等,努力执行中"
msgid "Expand application space overlay (/overlay)"
msgstr "用于overlay软件空间 (/overlay)"
msgid "Use as root filesystem (/)"
msgstr "用作根文件系统(/"
msgid "Used as Docker data disk (/opt)"
msgstr "用作Docker数据盘 (/opt)"
msgid "Normal mount and use by device name(/dev/x1)"
msgstr "按设备名普通挂载使用(/dev/x1)"
msgid "Soft chain partition expansion(/overlay)"
msgstr "分区软链扩容(/overlay)"
msgid "Destination hard disk"
msgstr "目标硬盘"
msgid "Keep configuration"
msgstr "保留配置"
msgid "Format before use"
msgstr "使用前格式化"
msgid "Select the hard disk device to operate"
msgstr "选择需要操作的硬盘设备"
msgid "Select function"
msgstr "选择功能"
msgid "Click to execute"
msgstr "点击执行"
msgid "Perform operation"
msgstr "执行操作"
msgid "To make the operation effective, the device will restart. Are you sure to execute?"
msgstr "警告:操作一旦确定无法取消,设备将会重启,是否确定执行?"
msgid "Operation in progress, please wait..."
msgstr "操作执行中,请稍候..."
msgid "After operation, restart the machine, please wait..."
msgstr "操作完毕,机器重启,请稍候..."
msgid "Please delete the partition or share and try again"
msgstr "错误,请检查是否有足够空间或是共享使用中。"
msgid "Restart the device to take effect. Confirm whether to continue?"
msgstr "重启设备操作才生效,确定是否继续执行?"
msgid "Operation execution complete"
msgstr "操作执行完毕"
msgid "Ticking indicates formatting"
msgstr "打勾选择表示格式化"
msgid "Tick means to retain the settings"
msgstr "打勾选择表示保留设置"

View File

@ -0,0 +1,76 @@
msgid ""
msgstr ""
"Copyright (C) 2022-2024 sirpdboy herboy2008@gmail.com https://github.com/sirpdboy/luci-app-partexp"
"This is free software, licensed under the GNU General Public License v3."
msgid "Partition Expansion"
msgstr "分区扩容"
msgid "One click partition expansion mounting tool"
msgstr "一键分区扩容挂载工具"
msgid "Automatically format and mount the target device partition. If there are multiple partitions, it is recommended to manually delete all partitions before using this tool.<br/>For specific usage, see:"
msgstr "自动对目标设备分区格式化挂载,如果有多分区建议手动删除所有分区再使用本工具.<br/>使用说明见:"
msgid "Waiting,(executing)..."
msgstr "稍等,努力执行中"
msgid "Expand application space overlay (/overlay)"
msgstr "用于overlay软件空间 (/overlay)"
msgid "Use as root filesystem (/)"
msgstr "用作根文件系统(/"
msgid "Used as Docker data disk (/opt)"
msgstr "用作Docker数据盘 (/opt)"
msgid "Normal mount and use by device name(/dev/x1)"
msgstr "按设备名普通挂载使用(/dev/x1)"
msgid "Soft chain partition expansion(/overlay)"
msgstr "分区软链扩容(/overlay)"
msgid "Destination hard disk"
msgstr "目标硬盘"
msgid "Keep configuration"
msgstr "保留配置"
msgid "Format before use"
msgstr "使用前格式化"
msgid "Select the hard disk device to operate"
msgstr "选择需要操作的硬盘设备"
msgid "Select function"
msgstr "选择功能"
msgid "Click to execute"
msgstr "点击执行"
msgid "Perform operation"
msgstr "执行操作"
msgid "To make the operation effective, the device will restart. Are you sure to execute?"
msgstr "警告:操作一旦确定无法取消,设备将会重启,是否确定执行?"
msgid "Operation in progress, please wait..."
msgstr "操作执行中,请稍候..."
msgid "After operation, restart the machine, please wait..."
msgstr "操作完毕,机器重启,请稍候..."
msgid "Please delete the partition or share and try again"
msgstr "错误,请检查是否有足够空间或是共享使用中。"
msgid "Restart the device to take effect. Confirm whether to continue?"
msgstr "重启设备操作才生效,确定是否继续执行?"
msgid "Operation execution complete"
msgstr "操作执行完毕"
msgid "Ticking indicates formatting"
msgstr "打勾选择表示格式化"
msgid "Tick means to retain the settings"
msgstr "打勾选择表示保留设置"

View File

@ -1,4 +1,4 @@
config global config global 'global'
option target_function '/overlay' option target_function '/overlay'
option target_disk '' option target_disk ''
option keep_config '0' option keep_config '0'

View File

@ -29,18 +29,17 @@ limit_log() {
init_env() { init_env() {
[ -d "$LOGD" ] || mkdir -p $LOGD [ -d "$LOGD" ] || mkdir -p $LOGD
[ ! -f "$LOG" ] && echo "" > $LOG [ ! -f "$LOG" ] && echo " " > $LOG
} }
gen_log()( gen_log()(
[ -s $LOG ] && echo " ---------------------------------------------------------------------- " >> $LOG log "---------------自动分区扩展挂载开始执行------------------ "
log "自动分区扩展挂载开始执行..."
) )
log(){ log(){
echo " $(date +'%Y-%m-%d %H:%M:%S') $*" >> $LOG echo -e " $(date +'%Y-%m-%d %H:%M:%S') $*"
} }
@ -69,15 +68,15 @@ s=$1
s2=$2 s2=$2
[ -e "/etc/config/$s" ] && { [ -e "/etc/config/$s" ] && {
msum=$(grep -c "config sambashare" /etc/config/$s) msum=$(grep -c "config sambashare" /etc/config/$s)
for i in $(seq 0 $((msum-1))) for i in $(seq 0 $((msum)))
do do
dev=`uci -q get $s.@sambashare[$i].device ` pdev=`uci -q get $s.@sambashare[$i].path `
[ $? -ne 0 ] && break [ "$pdev" = "$s2" ] && {
[ "$dev" = "$s2" ] && {
uci delete $s.@sambashare[$i] uci delete $s.@sambashare[$i]
uci commit uci commit $s
/etc/init.d/$s restart log "分区/dev/$b被挂载$MOUNT共享使用删除$s共享成功"
sleep 5 sleep 5
/etc/init.d/$s restart
} }
done done
} }
@ -98,7 +97,6 @@ fdiskB(){
else else
isfdisk=2 isfdisk=2
fi fi
isP=`fdisk -l /dev/$a |grep -v "bytes" | grep "/dev/$b"` isP=`fdisk -l /dev/$a |grep -v "bytes" | grep "/dev/$b"`
if [ "$isP" -a "$isfdisk" = 1 ] ;then if [ "$isP" -a "$isfdisk" = 1 ] ;then
@ -109,27 +107,24 @@ fdiskB(){
log "分区$b建立失败没有足够的空间操作失败" log "分区$b建立失败没有足够的空间操作失败"
expquit 1 expquit 1
fi fi
sleep 1
[ -e "/etc/config/dockerd" ] && /etc/init.d/dockerd stop >/dev/null 2> /dev/null
block detect > /etc/config/fstab block detect > /etc/config/fstab
isD=` block info "/dev/$b" ` isD=` block info "/dev/$b" `
if [ "$isD" ];then if [ "$isD" ];then
MOUNT='';eval $(block info "/dev/$b" | grep -o -e "MOUNT=\S*") MOUNT='';eval $(block info "/dev/$b" | grep -o -e "MOUNT=\S*")
log "检测/dev/$b是不是被共享..." log "检测/dev/$b是不是被共享..."
sleep 1 if [ "x$MOUNT" != 'x' ] ; then
if [ "$MOUNT" ] ; then usamba samba4 $MOUNT
usamba samba4 $b usamba samba $MOUNT
usamba samba $b
block detect > /etc/config/fstab
sleep 5 sleep 5
umount $MOUNT || block umount /dev/$b umount $MOUNT || block umount /dev/$b
sleep 5 sleep 5
MOUNT='';eval $(block info "/dev/$b" | grep -o -e "MOUNT=\S*") MOUNT='';eval $(block info "/dev/$b" | grep -o -e "MOUNT=\S*")
if [ "$MOUNT" ] ;then if [ "x$MOUNT" != 'x' ] ;then
log "分区/dev/$b挂载$MOUNT使用中,已执行删除共享操作!请重新执行!如果不行请手动删除共享或者取消其它插件的占用权限再重试!" log "分区/dev/$b挂载$MOUNT使用中,自动删除失败!请手动删除共享或者取消其它插件的占用权限再重试!"
expquit 1 expquit 1
else
log "分区/dev/$b被挂载$MOUNT共享使用自动删除共享成功"
fi fi
else else
log "检测目标设备$b未被共享..." log "检测目标设备$b未被共享..."
@ -152,8 +147,7 @@ fdiskB(){
[ -d "/mnt/$b" ] || mkdir -p /mnt/$b [ -d "/mnt/$b" ] || mkdir -p /mnt/$b
MOUNT='';eval $(block info "/dev/$b" | grep -o -e "MOUNT=\S*") MOUNT='';eval $(block info "/dev/$b" | grep -o -e "MOUNT=\S*")
echo "test40:$b" if [ "x$MOUNT" != 'x' ] ;then
if [ "$MOUNT" ] ;then
umount /mnt/$b || block umount /dev/$b umount /mnt/$b || block umount /dev/$b
MOUNT='';eval $(block info "/dev/$b" | grep -o -e "MOUNT=\S*") MOUNT='';eval $(block info "/dev/$b" | grep -o -e "MOUNT=\S*")
if [ "$MOUNT" ] ; then if [ "$MOUNT" ] ; then
@ -162,12 +156,19 @@ fdiskB(){
fi fi
fi fi
TYPE='';eval $(block info "/dev/$b" | grep -o -e "TYPE=\S*") TYPE='';eval $(block info "/dev/$b" | grep -o -e "TYPE=\S*")
log "检测设备/dev/$b分区是$TYPE格式"
if [ "$TYPE" = "ntfs" ];then if [ "$TYPE" = "ntfs" ];then
mount -t ntfs-3g /dev/$b /mnt/$b >/dev/null 2> /dev/null if [ `which ntfs-3g ` ] ;then
mount -t ntfs-3g /dev/$b /mnt/$b >/dev/null 2> /dev/null
elif [ `which ntfs3 ` ] ;then
mount -t ntfs3 /dev/$b /mnt/$b >/dev/null 2> /dev/null
else
log "不支持NTFS分区挂载请安装ntfs-3g或者ntfs3支持服务"
expquit 1
fi
else else
mount /dev/$b /mnt/$b >/dev/null 2> /dev/null mount /dev/$b /mnt/$b >/dev/null 2> /dev/null
fi fi
log "检测设备/dev/$b分区是$TYPE格式"
UUID='';eval $(block info /dev/$b | grep -o -e "UUID=\S*") UUID='';eval $(block info /dev/$b | grep -o -e "UUID=\S*")
if [ ! "$UUID" ] ; then if [ ! "$UUID" ] ; then
log "获取/dev/$b设备UUID信息失败" log "获取/dev/$b设备UUID信息失败"
@ -192,7 +193,7 @@ fdiskB(){
log "保留数据根目录扩展/dev/$b成功" log "保留数据根目录扩展/dev/$b成功"
seelp 5 seelp 5
log "设备重启才能生效,重启中..." log "设备重启才能生效"
expquit 2 expquit 2
elif [ "$target_function" = "/overlay" ] ; then elif [ "$target_function" = "/overlay" ] ; then
@ -222,7 +223,7 @@ fdiskB(){
uci commit fstab uci commit fstab
log "保留数据overlay扩展/dev/$b成功" log "保留数据overlay扩展/dev/$b成功"
seelp 5 seelp 5
log "设备重启才能生效,重启中..." log "设备重启才能生效"
expquit 2 expquit 2
else else
@ -250,10 +251,30 @@ fdiskB(){
log "不保留数据overlay扩展/dev/$b成功" log "不保留数据overlay扩展/dev/$b成功"
seelp 5 seelp 5
log "设备重启才能生效,重启中..." log "设备重启才能生效"
expquit 2 expquit 2
fi fi
elif [ "$target_function" = "/lnoverlay" ] ; then
umount /mnt/$b || block umount /dev/$b
block detect > /etc/config/fstab
mkdir -p $target_function
msum=$(grep -c "'mount'" /etc/config/fstab)
for i in $(seq 0 $((msum-1)))
do
zuuid=`uci -q get fstab.@mount[$i].uuid `
[ $? -ne 0 ] && break
if [ "$zuuid" = "$UUID" ] ; then
uci -q set fstab.@mount[$i].target="/mnt/$b"
uci -q set fstab.@mount[$i].enabled='1'
fi
done
uci commit fstab
ln -sf /mnt/$b /overlay
log "设备/dev/$b挂载/mnt/$b软链到/overlay扩容成功"
log "设备重启才能生效"
expquit 2
else else
umount /mnt/$b || block umount /dev/$b umount /mnt/$b || block umount /dev/$b
@ -273,7 +294,7 @@ fdiskB(){
done done
uci commit fstab uci commit fstab
[ "$target_function" = "/opt" ] && log "挂载/dev/$b到$target_function成功" || log "挂载/dev/$b到/mnt/$b成功" [ "$target_function" = "/opt" ] && log "挂载/dev/$b到$target_function成功" || log "挂载/dev/$b到/mnt/$b成功"
log "设备重启才能生效,重启中..." log "设备重启才能生效"
expquit 2 expquit 2
fi fi
@ -284,10 +305,9 @@ autopart() {
config_load partexp config_load partexp
config_foreach get_config global config_foreach get_config global
init_env init_env
limit_log $LOG 500
# touch $LOCK # touch $LOCK
cat $LOG 2>/dev/null | sed -n '$p' | grep -q '自动分区扩展挂载开始执行...' || gen_log gen_log
log "此次执行操作功能:$target_function ,目标盘:/dev/$target_disk"
isP=`fdisk -l /dev/$target_disk |grep "Disk /dev/$target_disk"` isP=`fdisk -l /dev/$target_disk |grep "Disk /dev/$target_disk"`
if [ "$isP" = "" ];then if [ "$isP" = "" ];then
log "没有检测到/dev/$target_disk目标设备操作失败" log "没有检测到/dev/$target_disk目标设备操作失败"
@ -325,11 +345,10 @@ autopart() {
esac esac
fi fi
# rm -f $LOCK rm -f $LOCK
} }
start() { start() {
init_env
[ x$x = x1 ] && exit || autopart [ x$x = x1 ] && exit || autopart
} }
@ -340,7 +359,8 @@ x=1
expquit() { expquit() {
rm -f $LOCK rm -f $LOCK
echo $1 [ -e "/etc/config/dockerd" ] && /etc/init.d/dockerd restart >/dev/null 2> /dev/null
[ $1 == 2 ] &&reboot sleep 5
[ $1 == 2 ] && log "重启中...\n" &&reboot
exit $1 exit $1
} }

View File

@ -0,0 +1 @@
1043

View File

@ -0,0 +1 @@
1

View File

@ -1,5 +1,11 @@
#!/bin/sh #!/bin/sh
chmod +x /etc/init.d/partexp >/dev/null 2>&1 chmod +x /etc/init.d/partexp >/dev/null 2>&1
[ `uci -q get partexp.global` ] || uci set partexp.global=global
LOGD=/etc/partexp
LOG=$LOGD/partexp.log
LOGPOS=$LOGD/lucilogpos
[ -d "$LOGD" ] || mkdir -p $LOGD
[ ! -f "$LOG" ] && echo "start" > $LOG
[ ! -f "$LOGPOS" ] && echo 'start' > $LOGPOS
rm -rf /tmp/luci-modulecache /tmp/luci-indexcache* rm -rf /tmp/luci-modulecache /tmp/luci-indexcache*
exit 0 exit 0