mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-10-31 15:35:13 +08:00
🌴 Sync 2026-03-05 23:51:42
This commit is contained in:
1 parent
97c049ed0a
commit
0acff03804
14253 files changed
+3893239
No files matched your search
@@ -0,0 +1,12 @@
|
||||
|
||||
config main
|
||||
option use_auth '1'
|
||||
list auth_users 'admin:$2y$10$BewzfQXrlnUihprEgGt7ROMB9NigZcZkkwssIRYznF9fwMuObIZoa'
|
||||
list auth_users 'user:$2y$10$Fg6Dz8oH9fPoZ2jJan5tZuv6Z4Kp7avtQ9bDfrdRntXtPeiMAZyGO'
|
||||
list readonly_users 'user'
|
||||
option date_format 'd.m.o'
|
||||
option time_format 'H:i:s'
|
||||
option show_second '0'
|
||||
option favicon_path '/tinyfilemanager/rootfs/etc/tinyfilemanager/favicon.png'
|
||||
option online_viewer '0'
|
||||
|
||||
+132
@@ -0,0 +1,132 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
# Copyright (C) 2022-2023 muink
|
||||
|
||||
. "${IPKG_INSTROOT}/lib/functions.sh"
|
||||
|
||||
START=99
|
||||
USE_PROCD=1
|
||||
VERSION='2.6'
|
||||
|
||||
EXTRA_COMMANDS="check"
|
||||
EXTRA_HELP=\
|
||||
" check Check for version updates"
|
||||
|
||||
CONFIG_NAME='tinyfilemanager'
|
||||
TYPEDSECTION='main'
|
||||
|
||||
WORKDIR="/www/tinyfilemanager"
|
||||
VARDIR="/var/tinyfilemanager"
|
||||
CONF="/var/etc/tinyfilemanager.conf"
|
||||
|
||||
HOMEPATH="tinyfilemanager/rootfs"
|
||||
|
||||
if [ "$(uci -q get $CONFIG_NAME.@$TYPEDSECTION[0].proxy_enabled)" == "1" ]; then
|
||||
export ALL_PROXY=$(uci -q get $CONFIG_NAME.@$TYPEDSECTION[0].proxy_protocol)://$(uci -q get $CONFIG_NAME.@$TYPEDSECTION[0].proxy_server)
|
||||
fi
|
||||
|
||||
|
||||
|
||||
validate_section() {
|
||||
uci_load_validate $CONFIG_NAME $TYPEDSECTION "$1" "$2" \
|
||||
'defconf:string' \
|
||||
'use_auth:bool:0' \
|
||||
'auth_users:list(string)' \
|
||||
'readonly_users:list(string)' \
|
||||
'global_readonly:bool:0' \
|
||||
'root_path:directory' \
|
||||
'date_format:or("d.m.o", "d-m-o", "d/m/o", "j.n.o", "j-n-o", "j/n/o", "o.m.d", "o-m-d", "o/m/d", "o.n.j", "o-n-j", "o/n/j"):d.m.o' \
|
||||
'time_format:or("H\:i\:s", "G\:i\:s", "A h\:i\:s", "A g\:i\:s", "h\:i\:s A", "g\:i\:s A"):H\:i\:s' \
|
||||
'show_second:bool:0' \
|
||||
'favicon_path:string' \
|
||||
'exclude_items:list(string)' \
|
||||
'online_viewer:or("0", "google", "microsoft"):0' \
|
||||
'max_upload_size:and(uinteger,max(2048))'
|
||||
}
|
||||
|
||||
init_config() {
|
||||
local defconf="$(sed -n '/^\/\/Default Configuration/,/^$/p' "$WORKDIR/index.php" | tr '\n' '|' | sed 's,|,\\n,g')"
|
||||
|
||||
sed -n "/\/\/ --- EDIT BELOW CONFIGURATION CAREFULLY ---/,/\/\/ --- EDIT BELOW CAREFULLY OR DO NOT EDIT AT ALL ---/{ \
|
||||
s|// --- EDIT BELOW CONFIGURATION CAREFULLY ---|\<?php\n$defconf|; \
|
||||
s|// --- EDIT BELOW CAREFULLY OR DO NOT EDIT AT ALL ---|?\>|; \
|
||||
/\/\/ if User has the external config file, try to use it to override the default config above/,/^}/d; \
|
||||
p \
|
||||
}" "$WORKDIR/index.php" > "$1"
|
||||
|
||||
sed -Ei "s|(^\\\$root_path =)(.+)|\1 \\\$_SERVER['DOCUMENT_ROOT'].'/$HOMEPATH';|; \
|
||||
s|(^\\\$root_url =)(.+)|\1 '$HOMEPATH';|; \
|
||||
|
||||
s|(^\\\$default_timezone =)(.+)|\1 '$(uci -q get system.@system[0].zonename)';| \
|
||||
" "$1"
|
||||
}
|
||||
|
||||
apply_config() {
|
||||
[ "$2" == "0" ] || { >&2 echo "section $1 validation failed"; return 1; }
|
||||
|
||||
local _conf="$CONF"
|
||||
|
||||
local auth_users=$(echo "$auth_users"|sed -E "s/('[^']+'|[^' ]+)/'\1'/g; s|:|' => '|g; s|''|'|g; s|' '|',\\\n '|g; s|^| |")
|
||||
local readonly_users=$(echo "$readonly_users"|sed -E "s/('[^']+'|[^' ]+)/'\1'/g; s|''|'|g; s|' '|',\\\n '|g; s|^| |")
|
||||
|
||||
local exclude_items=$(echo "$exclude_items"|sed -E "s/('[^']+'|[^' ]+)/'\1'/g; s|''|'|g; s|' '|',\\\n '|g; s|^| |")
|
||||
|
||||
[ -n "$defconf" ] && sed -Ei "s|^\\\$CONFIG\s*=.*|\$CONFIG = '$defconf'\;|" "$_conf"
|
||||
[ "$use_auth" -eq "1" ] && sed -Ei "s|(^\\\$use_auth =)(.+)|\1 true;|" "$_conf" || sed -Ei "s|(^\\\$use_auth =)(.+)|\1 false;|" "$_conf"
|
||||
[ "$global_readonly" -eq "1" ] && sed -Ei "s|(^\\\$global_readonly =)(.+)|\1 true;|" "$_conf" || sed -Ei "s|(^\\\$global_readonly =)(.+)|\1 false;|" "$_conf"
|
||||
sed -Ei "/^\\\$auth_users /,/\);/{/^ /d}" "$_conf" && sed -Ei "/^\\\$auth_users /a\ $auth_users" "$_conf"
|
||||
sed -Ei "/^\\\$readonly_users /,/\);/{/^ /d}" "$_conf" && sed -Ei "/^\\\$readonly_users /a\ $readonly_users" "$_conf"
|
||||
sed -Ei "/^\\\$exclude_items /{s|array\(\);|array(\n);|}" "$_conf" && sed -Ei "/^\\\$exclude_items /a\ $exclude_items" "$_conf"
|
||||
sed -Ei "s|(^\\\$default_timezone =)(.+)|\1 '$(uci -q get system.@system[0].zonename)';|" "$_conf"
|
||||
if [ -n "$root_path" ]; then
|
||||
sed -Ei "s|(^\\\$root_path =)(.+)|\1 \\\$_SERVER['DOCUMENT_ROOT'].'/${HOMEPATH}$root_path';|; \
|
||||
s|(^\\\$root_url =)(.+)|\1 '${HOMEPATH}$root_path';| \
|
||||
" "$_conf"
|
||||
fi
|
||||
sed -Ei "s|(^\\\$datetime_format =)(.+)|\1 '$date_format $time_format';|" "$_conf"
|
||||
[ "$show_second" -eq "0" ] && sed -Ei "/^\\\$datetime_format =/{s|:s||}" "$_conf"
|
||||
sed -Ei "s|(^\\\$favicon_path =)(.+)|\1 '$favicon_path';|" "$_conf"
|
||||
if [ "$online_viewer" == "0" ]; then sed -Ei "s|(^\\\$online_viewer =)(.+)|\1 false;|" "$_conf"
|
||||
else sed -Ei "s|(^\\\$online_viewer =)(.+)|\1 '$online_viewer';|" "$_conf"
|
||||
fi
|
||||
if [ "$(( $max_upload_size +0 ))" == "0" ]; then sed -Ei "s|(^\\\$max_upload_size_bytes =)(.+)|\1 26214400;|" "$_conf" #25M
|
||||
else sed -Ei "s|(^\\\$max_upload_size_bytes =)(.+)|\1 $(( $max_upload_size * 1024**2 ));|" "$_conf"
|
||||
fi
|
||||
}
|
||||
|
||||
start_service() {
|
||||
mkdir /var/etc 2>/dev/null
|
||||
touch "$CONF"
|
||||
ln -s "$CONF" "$WORKDIR/config.php" 2>/dev/null
|
||||
init_config "$CONF"
|
||||
|
||||
config_load "$CONFIG_NAME"
|
||||
config_foreach validate_section "$TYPEDSECTION" apply_config
|
||||
|
||||
# CONFIG save
|
||||
procd_open_instance "config-save"
|
||||
procd_set_param command "/usr/libexec/tinyfilemanager-config-save"
|
||||
procd_set_param env CONF=$CONF
|
||||
procd_set_param respawn
|
||||
#procd_set_param stdout 1
|
||||
#procd_set_param stderr 1
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger "$CONFIG_NAME" 'system'
|
||||
}
|
||||
|
||||
check() {
|
||||
local owner='prasathmani'
|
||||
local repo='tinyfilemanager'
|
||||
mkdir $VARDIR 2>/dev/null
|
||||
curl -sSL https://api.github.com/repos/$owner/$repo/releases \
|
||||
| grep '"tag_name":' | sed "/$VERSION/,\${/$VERSION/b;d}" \
|
||||
| sed -E 's|",||g; s|^.+"([^"]+)|\1|g' \
|
||||
> "$VARDIR/releaseslist"
|
||||
[ "$?" != 0 ] || sed -i 'i\master' "$VARDIR/releaseslist"
|
||||
}
|
||||
|
||||
reload_service() {
|
||||
restart "$@"
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
location = /tinyfilemanager/ {
|
||||
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
|
||||
if (!-f $document_root$fastcgi_script_name) {
|
||||
return 404;
|
||||
}
|
||||
|
||||
# Mitigate https://httpoxy.org/ vulnerabilities
|
||||
fastcgi_param HTTP_PROXY "";
|
||||
|
||||
#error_log /dev/null;
|
||||
fastcgi_connect_timeout 300s;
|
||||
fastcgi_read_timeout 300s;
|
||||
fastcgi_send_timeout 300s;
|
||||
fastcgi_buffer_size 32k;
|
||||
fastcgi_buffers 4 32k;
|
||||
fastcgi_busy_buffers_size 32k;
|
||||
fastcgi_temp_file_write_size 32k;
|
||||
client_body_timeout 10s;
|
||||
send_timeout 60s; # default, increase if experiencing a lot of timeouts.
|
||||
output_buffers 1 32k;
|
||||
fastcgi_index index.php;
|
||||
include fastcgi_params;
|
||||
|
||||
# Only throw it at PHP-FPM if file exists (prevents PHP exploits).
|
||||
fastcgi_pass 127.0.0.1:1026; # or: unix:/var/run/php-fpm.sock;
|
||||
# fastcgi_pass unix:/var/run/php8-fpm.sock;
|
||||
|
||||
# SCRIPT_FILENAME parameter is used for PHP FPM determining
|
||||
# the script name. If it is not set in fastcgi_params file,
|
||||
# i.e. /etc/nginx/fastcgi_params or in the parent contexts,
|
||||
# please comment off following line:
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 234 B |
@@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
|
||||
# uhttpd
|
||||
uci -q get uhttpd.main.index_page|grep -i 'index.php' >/dev/null || uci add_list uhttpd.main.index_page='index.php'
|
||||
uci -q get uhttpd.main.interpreter|grep -i '.php=/usr/bin/php-cgi' >/dev/null || uci add_list uhttpd.main.interpreter='.php=/usr/bin/php-cgi'
|
||||
uci changes uhttpd|grep . >/dev/null && uci commit uhttpd
|
||||
/etc/init.d/uhttpd reload
|
||||
|
||||
# nginx
|
||||
[ -n "$(command -v nginx)" ] && /etc/init.d/nginx reload
|
||||
|
||||
exit 0
|
||||
@@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
|
||||
CONFIG_NAME='tinyfilemanager'
|
||||
|
||||
while :; do
|
||||
inotifywait -e modify $CONF 2>/dev/null
|
||||
|
||||
CONFIG="$(sed -En "/^\\\$CONFIG\s*=.*/{s|^.+'(.+)'.*|\1|p}" $CONF)"
|
||||
if [ -n "$CONFIG" ]; then
|
||||
uci set $CONFIG_NAME.@$TYPEDSECTION[0].defconf="$CONFIG"
|
||||
[ -z "$(uci changes $CONFIG_NAME)" ] || uci commit $CONFIG_NAME
|
||||
fi
|
||||
done
|
||||
@@ -0,0 +1,133 @@
|
||||
#!/bin/bash
|
||||
# dependent: curl tar
|
||||
#
|
||||
# LuCI Tiny File Manager
|
||||
# Author: muink
|
||||
# Github: https://github.com/muink/luci-app-tinyfilemanager
|
||||
#
|
||||
|
||||
# PKGInfo
|
||||
REPOURL='https://github.com/prasathmani/tinyfilemanager'
|
||||
PKGNAME='tinyfilemanager'
|
||||
VERSION="$1"; VERSION="${VERSION:=2.6}"
|
||||
#
|
||||
PKG_DIR=$PKGNAME-$VERSION
|
||||
REF_DIR="assets"
|
||||
#
|
||||
INDEXPHP="tinyfilemanager.php"
|
||||
#CFGSAMPl="config-sample.php"
|
||||
LANGFILE="translation.json"
|
||||
|
||||
|
||||
WORKDIR="/www/$PKGNAME"
|
||||
mkdir -p "$WORKDIR" 2>/dev/null
|
||||
cd $WORKDIR
|
||||
|
||||
if [ "$(uci -q get $PKGNAME.@main[0].proxy_enabled)" == "1" ]; then
|
||||
export ALL_PROXY=$(uci -q get $PKGNAME.@main[0].proxy_protocol)://$(uci -q get $PKGNAME.@main[0].proxy_server)
|
||||
fi
|
||||
|
||||
|
||||
|
||||
# Clear Old version
|
||||
rm -rf *
|
||||
|
||||
# Download Repository
|
||||
grep -qE "^(master|main)$" <<< "$VERSION" && refs=heads || refs=tags
|
||||
curl -sSL https://codeload.github.com/prasathmani/tinyfilemanager/tar.gz/refs/$refs/$VERSION | tar -xvz -C /tmp
|
||||
|
||||
# Version Check
|
||||
if [ -z "$(sed -En "/^\\\$external = array\(/,/^\);/p" /tmp/$PKG_DIR/$INDEXPHP)" ]; then
|
||||
online=y ver_cc=old # <= 2.5.3
|
||||
elif [ -n "$(sed -En "/^\\\$external = array\(/,/^\);/{s,^(.+=\")(http(s)?://.+/)([^/]+\.(css|js))(\".+),\4,p}" /tmp/$PKG_DIR/$INDEXPHP)" ]; then
|
||||
online=y ver_cc=master
|
||||
else
|
||||
online=n ver_cc=offline
|
||||
fi
|
||||
[ "$online" = "y" ] && {
|
||||
|
||||
# Preprocessing
|
||||
sed -Ei "/<link rel=\"(preconnect|dns-prefetch)\"/d" /tmp/$PKG_DIR/$INDEXPHP
|
||||
[ "$ver_cc" = "old" ] && {
|
||||
FM_HIGHLIGHTJS_STYLE=$(sed -En "s|^\\\$highlightjs_style = *'([^']*)';|\1|p" /tmp/$PKG_DIR/$INDEXPHP)
|
||||
sed -i "s|<?php echo FM_HIGHLIGHTJS_STYLE ?>|\$FM_HIGHLIGHTJS_STYLE|g" /tmp/$PKG_DIR/$INDEXPHP
|
||||
}
|
||||
[ "$ver_cc" = "master" ] && {
|
||||
__highlightjs_style=$(sed -En "s|^\\\$highlightjs_style = *'([^']*)';|\1|p" /tmp/$PKG_DIR/$INDEXPHP)
|
||||
sed -i "s|' . \$highlightjs_style . '|\$__highlightjs_style|" /tmp/$PKG_DIR/$INDEXPHP
|
||||
}
|
||||
|
||||
# Download CDN Used
|
||||
mkdir -p "$REF_DIR" 2>/dev/null
|
||||
[ "$ver_cc" = "old" ] && refurl=($(sed -En "s,^.+=\"(https?://.+\.(css|js))\".+,\1,p" /tmp/$PKG_DIR/$INDEXPHP | sort -u ))
|
||||
[ "$ver_cc" = "master" ] && refurl=($(sed -En "/^\\\$external /,/^\);/{s,^.+=\"(http(s)?://.+\.(css|js))\".+,\1, p}" /tmp/$PKG_DIR/$INDEXPHP | sort -u ))
|
||||
ref=
|
||||
url=
|
||||
out=
|
||||
path=
|
||||
|
||||
# \.(css|js) main ref
|
||||
for _i in $(seq 0 1 $[ ${#refurl[@]} -1 ]); do
|
||||
eval "url=${refurl[$_i]}"
|
||||
out=${url##*/}
|
||||
path="$REF_DIR/${url#http*://}"
|
||||
|
||||
mkdir -p "${path%/*}" 2>/dev/null
|
||||
curl -sSLo $out $url
|
||||
mv -f $out "${path%/*}"
|
||||
done
|
||||
|
||||
ref=$(for _p in $(find * -type f); do \
|
||||
sed -E "s/(,|;)/\1\n/g" $_p | grep -E "\burl\([^\)]+\)" | grep -Ev "\burl\(\"data:image" >/dev/null; \
|
||||
[ "$?" == "0" ] && echo $_p; \
|
||||
done)
|
||||
|
||||
# ref of main ref
|
||||
for _i in $ref; do
|
||||
suburl=($(sed -E "s/(,|;)/\1\n/g" $_i | grep -E "\burl\([^\)]+\)" | grep -Ev "\burl\(\"data:image" | sed -En "s|^[^']+'([^']+)'.+|\1| p"))
|
||||
hosturl=$(for _ in "${refurl[@]}"; do grep "${_i##*/}" <<< "$_"; done)
|
||||
|
||||
for _j in $(seq 0 1 $[ ${#suburl[@]} -1 ]); do
|
||||
url="${suburl[$_j]}"
|
||||
out=${url%%\?*}
|
||||
path="$REF_DIR/${hosturl#http*://}"
|
||||
|
||||
mkdir -p "${path%/*}/${out%/*}" 2>/dev/null
|
||||
curl -sSLo ${out##*/} "${hosturl%/*}/$url"
|
||||
mv -f ${out##*/} "${path%/*}/$out"
|
||||
done
|
||||
done
|
||||
|
||||
# Post-processing
|
||||
[ "$ver_cc" = "old" ] && sed -i "s|\$FM_HIGHLIGHTJS_STYLE|<?php echo FM_HIGHLIGHTJS_STYLE ?>|g" /tmp/$PKG_DIR/$INDEXPHP
|
||||
[ "$ver_cc" = "master" ] && sed -i "s|\$__highlightjs_style|' . \$highlightjs_style . '|" /tmp/$PKG_DIR/$INDEXPHP
|
||||
|
||||
# Hotfix
|
||||
|
||||
# Migrating to Local Reference
|
||||
sed -Ei "s,^(.+=\")https?://(.+\.(css|js))(\".+),\1$REF_DIR/\2\4," /tmp/$PKG_DIR/$INDEXPHP
|
||||
|
||||
}
|
||||
|
||||
# FixED
|
||||
[ "$ver_cc" = "master" ] || sed -Ei "/^if \(\\\$use_auth\) \{/,/^}/{/\/\/ Logging In/,/\/\/ Form/{s|(fm_redirect\().+|\1FM_SELF_URL);|g}}" /tmp/$PKG_DIR/$INDEXPHP
|
||||
|
||||
# Clean up and Done
|
||||
[ -d "/tmp/$PKG_DIR/$REF_DIR" ] && cp -rf "/tmp/$PKG_DIR/$REF_DIR" .
|
||||
mv -f /tmp/$PKG_DIR/$INDEXPHP ./index.php
|
||||
#mv -f /tmp/$PKG_DIR/$CFGSAMPl .
|
||||
mv -f /tmp/$PKG_DIR/$LANGFILE .
|
||||
find * -type d -exec chmod 755 {} \;
|
||||
find * -type f -exec chmod 644 {} \;
|
||||
[ ! -d /www/tinyfilemanager/rootfs ] && ln -s / /www/tinyfilemanager/rootfs
|
||||
/etc/init.d/tinyfilemanager start
|
||||
|
||||
|
||||
|
||||
#$(INSTALL_DIR) $(1)/usr/libexec
|
||||
#$(INSTALL_DIR) $(1)/www/$PKGNAME
|
||||
#$(INSTALL_BIN) run.sh $(1)/usr/libexec/$PKGNAME
|
||||
#$(CP) $PKG_DIR/$INDEXPHP $(1)/www/$PKGNAME/index.php
|
||||
#$(CP) $PKG_DIR/$CFGSAMPl $(1)/www/$PKGNAME/$CFGSAMPl
|
||||
#$(CP) $PKG_DIR/$LANGFILE $(1)/www/$PKGNAME/$LANGFILE
|
||||
#$(CP) --parents -rf $REF_DIR/ $(1)/www/$PKGNAME/
|
||||
@@ -0,0 +1,37 @@
|
||||
{
|
||||
"admin/nas": {
|
||||
"title": "NAS",
|
||||
"order": 44,
|
||||
"action": {
|
||||
"type": "firstchild",
|
||||
"recurse": true
|
||||
}
|
||||
},
|
||||
"admin/nas/tinyfilemanager": {
|
||||
"title": "Tiny File Manager",
|
||||
"order": 10,
|
||||
"action": {
|
||||
"type": "firstchild"
|
||||
},
|
||||
"depends": {
|
||||
"acl": [ "luci-app-tinyfilemanager" ],
|
||||
"uci": { "tinyfilemanager": true }
|
||||
}
|
||||
},
|
||||
"admin/nas/tinyfilemanager/tinyfilemanager": {
|
||||
"title": "Tiny File Manager",
|
||||
"order": 1,
|
||||
"action": {
|
||||
"type": "view",
|
||||
"path": "tinyfilemanager/main"
|
||||
}
|
||||
},
|
||||
"admin/nas/tinyfilemanager/config": {
|
||||
"title": "Config",
|
||||
"order": 2,
|
||||
"action": {
|
||||
"type": "view",
|
||||
"path": "tinyfilemanager/config"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"luci-app-tinyfilemanager": {
|
||||
"description": "Grant access to tinyfilemanager procedures",
|
||||
"read": {
|
||||
"file": {
|
||||
"/usr/libexec/tinyfilemanager-update": [ "exec" ],
|
||||
"/etc/init.d/tinyfilemanager check": [ "exec" ],
|
||||
"/etc/init.d/tinyfilemanager reload": [ "exec" ],
|
||||
"/var/tinyfilemanager/releaseslist": [ "read" ]
|
||||
},
|
||||
"uci": [ "tinyfilemanager" ]
|
||||
},
|
||||
"write": {
|
||||
"uci": [ "tinyfilemanager" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user