Update code
This commit is contained in:
5
Moodle/SH/agets.sh
Normal file
5
Moodle/SH/agets.sh
Normal file
@@ -0,0 +1,5 @@
|
||||
aria2c -x 16 --content-disposition-default-utf8=true --check-certificate=false -i list.txt \
|
||||
--continue=true \
|
||||
--check-integrity=true \
|
||||
--max-concurrent-downloads=5 \
|
||||
--log=aria2.log --log-level=notice
|
62
Moodle/SH/batch_run.sh
Normal file
62
Moodle/SH/batch_run.sh
Normal file
@@ -0,0 +1,62 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Kiểm tra có đối số không
|
||||
if [ -z "$1" ] || [ -z "$2" ]; then
|
||||
echo "Usage: $(basename "$0") <arg1> <arg2>"
|
||||
exit 1
|
||||
fi
|
||||
siteid=$1
|
||||
courseid=$2
|
||||
|
||||
# Lưu thư mục hiện tại (nơi chạy script, không phải nơi đặt script)
|
||||
BASEDIR="$(pwd)"
|
||||
|
||||
for dir in */ ; do
|
||||
# Bỏ dấu '/' cuối
|
||||
dirname="${dir%/}"
|
||||
|
||||
# Cắt phần số trước dấu '.' và trim khoảng trắng
|
||||
index=$(echo "$dirname" | cut -d'.' -f1 | tr -d '[:space:]')
|
||||
|
||||
# Bỏ số 0 đầu nếu có
|
||||
index_nozero=$(echo "$index" | sed 's/^0*//')
|
||||
|
||||
# Nếu chuỗi rỗng (trường hợp '0')
|
||||
if [ -z "$index_nozero" ]; then
|
||||
index_nozero=0
|
||||
fi
|
||||
|
||||
# Kiểm tra là số hợp lệ
|
||||
if [[ "$index_nozero" =~ ^[0-9]+$ ]]; then
|
||||
# Tính i-1
|
||||
i_minus_1=$((index_nozero - 1))
|
||||
|
||||
echo "===> Đang xử lý thư mục: $dirname (index: $index_nozero, i-1: $i_minus_1)"
|
||||
|
||||
# Chuyển vào thư mục
|
||||
cd "$dirname" || { echo "Không thể vào thư mục $dirname"; exit 1; }
|
||||
|
||||
# Gọi online.sh với courseid từ dòng lệnh và i-1
|
||||
|
||||
case "$siteid" in
|
||||
1)
|
||||
online.sh "$courseid" "$i_minus_1"
|
||||
;;
|
||||
2)
|
||||
elearning.sh "$courseid" "$i_minus_1"
|
||||
;;
|
||||
3)
|
||||
english.sh "$courseid" "$i_minus_1"
|
||||
;;
|
||||
*)
|
||||
echo "Không hỗ trợ siteid=$siteid"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# Quay lại thư mục gốc
|
||||
cd "$BASEDIR"
|
||||
else
|
||||
echo "Bỏ qua $dirname (không bắt đầu bằng số)"
|
||||
fi
|
||||
done
|
7
Moodle/SH/create_course.sh
Normal file
7
Moodle/SH/create_course.sh
Normal file
@@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Lấy thư mục hiện tại nơi người dùng chạy lệnh
|
||||
CURRENT_DIR="$(pwd)"
|
||||
|
||||
# Gọi PHP script, truyền tham số đầu vào và thư mục hiện tại
|
||||
/usr/local/lsws/lsphp82/bin/php /usr/bin/create_moodle_course.php "$@" "$CURRENT_DIR"
|
7
Moodle/SH/createcourse.sh
Normal file
7
Moodle/SH/createcourse.sh
Normal file
@@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Lấy thư mục hiện tại nơi người dùng chạy lệnh
|
||||
CURRENT_DIR="$(pwd)"
|
||||
|
||||
# Gọi PHP script, truyền tham số đầu vào và thư mục hiện tại
|
||||
php /usr/bin/createcourse.php "$@" "$CURRENT_DIR"
|
47
Moodle/SH/ebatch_run.sh
Normal file
47
Moodle/SH/ebatch_run.sh
Normal file
@@ -0,0 +1,47 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Kiểm tra có đối số không
|
||||
if [ -z "$1" ]; then
|
||||
echo "Usage: $(basename "$0") <courseid>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
courseid="$1"
|
||||
|
||||
# Lưu thư mục hiện tại (nơi chạy script, không phải nơi đặt script)
|
||||
BASEDIR="$(pwd)"
|
||||
|
||||
for dir in */ ; do
|
||||
# Bỏ dấu '/' cuối
|
||||
dirname="${dir%/}"
|
||||
|
||||
# Cắt phần số trước dấu '.' và trim khoảng trắng
|
||||
index=$(echo "$dirname" | cut -d'.' -f1 | tr -d '[:space:]')
|
||||
|
||||
# Bỏ số 0 đầu nếu có
|
||||
index_nozero=$(echo "$index" | sed 's/^0*//')
|
||||
|
||||
# Nếu chuỗi rỗng (trường hợp '0')
|
||||
if [ -z "$index_nozero" ]; then
|
||||
index_nozero=0
|
||||
fi
|
||||
|
||||
# Kiểm tra là số hợp lệ
|
||||
if [[ "$index_nozero" =~ ^[0-9]+$ ]]; then
|
||||
# Tính i-1
|
||||
i_minus_1=$((index_nozero - 1))
|
||||
|
||||
echo "===> Đang xử lý thư mục: $dirname (index: $index_nozero, i-1: $i_minus_1)"
|
||||
|
||||
# Chuyển vào thư mục
|
||||
cd "$dirname" || { echo "Không thể vào thư mục $dirname"; exit 1; }
|
||||
|
||||
# Gọi online.sh với courseid từ dòng lệnh và i-1
|
||||
elearning.sh "$courseid" "$i_minus_1"
|
||||
|
||||
# Quay lại thư mục gốc
|
||||
cd "$BASEDIR"
|
||||
else
|
||||
echo "Bỏ qua $dirname (không bắt đầu bằng số)"
|
||||
fi
|
||||
done
|
7
Moodle/SH/ecreate_course.sh
Normal file
7
Moodle/SH/ecreate_course.sh
Normal file
@@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Lấy thư mục hiện tại nơi người dùng chạy lệnh
|
||||
CURRENT_DIR="$(pwd)"
|
||||
|
||||
# Gọi PHP script, truyền tham số đầu vào và thư mục hiện tại
|
||||
php /usr/bin/ecreate_moodle_course.php "$@" "$CURRENT_DIR"
|
20
Moodle/SH/elearning.sh
Normal file
20
Moodle/SH/elearning.sh
Normal file
@@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Kiểm tra số lượng tham số đầu vào
|
||||
if [ "$#" -ne 2 ]; then
|
||||
echo "Usage: $0 <courseid> <topicid>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Gán tham số đầu vào vào biến
|
||||
COURSEID=$1
|
||||
TOPICID=$2
|
||||
|
||||
# Lấy đường dẫn thư mục hiện tại
|
||||
CURRENT_DIR=$(pwd)
|
||||
|
||||
# Chạy lệnh PHP với các tham số, sử dụng mdl.media từ thư mục hiện tại
|
||||
/usr/local/lsws/lsphp82/bin/php /home/elearning.huph.edu.vn/public_html/elearning/page.php "$CURRENT_DIR/mdl.media" "$COURSEID" "$TOPICID"
|
||||
|
||||
# Hiển thị thông báo hoàn tất
|
||||
echo "Command executed with mdl.media from $CURRENT_DIR, courseid=$COURSEID, and topicid=$TOPICID"
|
47
Moodle/SH/enbatch_run.sh
Normal file
47
Moodle/SH/enbatch_run.sh
Normal file
@@ -0,0 +1,47 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Kiểm tra có đối số không
|
||||
if [ -z "$1" ]; then
|
||||
echo "Usage: $(basename "$0") <courseid>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
courseid="$1"
|
||||
|
||||
# Lưu thư mục hiện tại (nơi chạy script, không phải nơi đặt script)
|
||||
BASEDIR="$(pwd)"
|
||||
|
||||
for dir in */ ; do
|
||||
# Bỏ dấu '/' cuối
|
||||
dirname="${dir%/}"
|
||||
|
||||
# Cắt phần số trước dấu '.' và trim khoảng trắng
|
||||
index=$(echo "$dirname" | cut -d'.' -f1 | tr -d '[:space:]')
|
||||
|
||||
# Bỏ số 0 đầu nếu có
|
||||
index_nozero=$(echo "$index" | sed 's/^0*//')
|
||||
|
||||
# Nếu chuỗi rỗng (trường hợp '0')
|
||||
if [ -z "$index_nozero" ]; then
|
||||
index_nozero=0
|
||||
fi
|
||||
|
||||
# Kiểm tra là số hợp lệ
|
||||
if [[ "$index_nozero" =~ ^[0-9]+$ ]]; then
|
||||
# Tính i-1
|
||||
i_minus_1=$((index_nozero - 1))
|
||||
|
||||
echo "===> Đang xử lý thư mục: $dirname (index: $index_nozero, i-1: $i_minus_1)"
|
||||
|
||||
# Chuyển vào thư mục
|
||||
cd "$dirname" || { echo "Không thể vào thư mục $dirname"; exit 1; }
|
||||
|
||||
# Gọi online.sh với courseid từ dòng lệnh và i-1
|
||||
english.sh "$courseid" "$i_minus_1"
|
||||
|
||||
# Quay lại thư mục gốc
|
||||
cd "$BASEDIR"
|
||||
else
|
||||
echo "Bỏ qua $dirname (không bắt đầu bằng số)"
|
||||
fi
|
||||
done
|
7
Moodle/SH/encreate_course.sh
Normal file
7
Moodle/SH/encreate_course.sh
Normal file
@@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Lấy thư mục hiện tại nơi người dùng chạy lệnh
|
||||
CURRENT_DIR="$(pwd)"
|
||||
|
||||
# Gọi PHP script, truyền tham số đầu vào và thư mục hiện tại
|
||||
php /usr/bin/encreate_moodle_course.php "$@" "$CURRENT_DIR"
|
7
Moodle/SH/encreatecourse.sh
Normal file
7
Moodle/SH/encreatecourse.sh
Normal file
@@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Lấy thư mục hiện tại nơi người dùng chạy lệnh
|
||||
CURRENT_DIR="$(pwd)"
|
||||
|
||||
# Gọi PHP script, truyền tham số đầu vào và thư mục hiện tại
|
||||
php /usr/bin/encreatecourse.php "$@" "$CURRENT_DIR"
|
20
Moodle/SH/english.sh
Normal file
20
Moodle/SH/english.sh
Normal file
@@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Kiểm tra số lượng tham số đầu vào
|
||||
if [ "$#" -ne 2 ]; then
|
||||
echo "Usage: $0 <courseid> <topicid>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Gán tham số đầu vào vào biến
|
||||
COURSEID=$1
|
||||
TOPICID=$2
|
||||
|
||||
# Lấy đường dẫn thư mục hiện tại
|
||||
CURRENT_DIR=$(pwd)
|
||||
|
||||
# Chạy lệnh PHP với các tham số, sử dụng mdl.media từ thư mục hiện tại
|
||||
/usr/local/lsws/lsphp82/bin/php /home/english.huph.edu.vn/public_html/english/page.php "$CURRENT_DIR/mdl.media" "$COURSEID" "$TOPICID"
|
||||
|
||||
# Hiển thị thông báo hoàn tất
|
||||
echo "Command executed with mdl.media from $CURRENT_DIR, courseid=$COURSEID, and topicid=$TOPICID"
|
26
Moodle/SH/genmedia.sh
Normal file
26
Moodle/SH/genmedia.sh
Normal file
@@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Thư mục gốc của khóa học
|
||||
COURSE_FOLDER="$(pwd)"
|
||||
|
||||
# Tìm tất cả các thư mục con
|
||||
mapfile -t DIRS < <(find "$COURSE_FOLDER" -type d)
|
||||
|
||||
for dir in "${DIRS[@]}"; do
|
||||
relative_path="${dir#*/vod/}"
|
||||
OUTPUT_JSON="$dir/mdl.media"
|
||||
|
||||
# Xóa tệp mdl.media cũ nếu tồn tại
|
||||
rm -f "$OUTPUT_JSON"
|
||||
|
||||
# Tìm và sắp xếp các file .mp3 và .mp4 theo thứ tự tự nhiên
|
||||
mapfile -d '' -t FILES < <(find "$dir" -maxdepth 1 -type f \( -name '*.mp3' -o -name '*.mp4' \) -print0 | sort -z -V)
|
||||
|
||||
for file in "${FILES[@]}"; do
|
||||
filename=$(basename "$file")
|
||||
vid="$relative_path/$filename"
|
||||
echo "[stream=$vid]" >> "$OUTPUT_JSON"
|
||||
done
|
||||
|
||||
echo "File mdl.media created successfully in $dir."
|
||||
done
|
32
Moodle/SH/genmedia.v.1.sh
Normal file
32
Moodle/SH/genmedia.v.1.sh
Normal file
@@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Thư mục gốc của khóa học
|
||||
COURSE_FOLDER="$(pwd)"
|
||||
|
||||
# Hàm xử lý tạo mdl.media cho mỗi thư mục
|
||||
process_dir() {
|
||||
local dir="$1"
|
||||
local relative_path="${dir#*/vod/}"
|
||||
|
||||
# Đường dẫn đến tệp mdl.media trong thư mục
|
||||
OUTPUT_JSON="$dir/mdl.media"
|
||||
|
||||
# Xóa tệp mdl.media cũ nếu tồn tại
|
||||
rm -f "$OUTPUT_JSON"
|
||||
|
||||
# Tìm và sắp xếp các file .mp4 theo thứ tự tự nhiên (hỗ trợ cả số có hoặc không có leading zeros)
|
||||
find "$dir" -maxdepth 1 -type f -name '*.mp4' -print0 | sort -z -V | while IFS= read -r -d '' file; do
|
||||
if [ -f "$file" ]; then
|
||||
filename=$(basename "$file")
|
||||
vid="$relative_path/$filename"
|
||||
echo "[stream=$vid]" >> "$OUTPUT_JSON"
|
||||
fi
|
||||
done
|
||||
|
||||
echo "File mdl.media created successfully in $dir."
|
||||
}
|
||||
|
||||
# Duyệt qua thư mục gốc và tất cả các thư mục con, gọi hàm xử lý
|
||||
find "$COURSE_FOLDER" -type d | while IFS= read -r dir; do
|
||||
process_dir "$dir"
|
||||
done
|
32
Moodle/SH/genmp3.sh
Normal file
32
Moodle/SH/genmp3.sh
Normal file
@@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Thư mục gốc của khóa học
|
||||
COURSE_FOLDER="$(pwd)"
|
||||
|
||||
# Hàm xử lý tạo mdl.media cho mỗi thư mục
|
||||
process_dir() {
|
||||
local dir="$1"
|
||||
local relative_path="${dir#*/vod/}"
|
||||
|
||||
# Đường dẫn đến tệp mdl.media trong thư mục
|
||||
OUTPUT_JSON="$dir/mdl.media"
|
||||
|
||||
# Xóa tệp mdl.media cũ nếu tồn tại
|
||||
rm -f "$OUTPUT_JSON"
|
||||
|
||||
# Tìm và sắp xếp các file .mp3 theo thứ tự tự nhiên (hỗ trợ cả số có hoặc không có leading zeros)
|
||||
find "$dir" -maxdepth 1 -type f -name '*.mp3' -print0 | sort -z -V | while IFS= read -r -d '' file; do
|
||||
if [ -f "$file" ]; then
|
||||
filename=$(basename "$file")
|
||||
vid="$relative_path/$filename"
|
||||
echo "[stream=$vid]" >> "$OUTPUT_JSON"
|
||||
fi
|
||||
done
|
||||
|
||||
echo "File mdl.media created successfully in $dir."
|
||||
}
|
||||
|
||||
# Duyệt qua thư mục gốc và tất cả các thư mục con, gọi hàm xử lý
|
||||
find "$COURSE_FOLDER" -type d | while IFS= read -r dir; do
|
||||
process_dir "$dir"
|
||||
done
|
2
Moodle/SH/gets.sh
Normal file
2
Moodle/SH/gets.sh
Normal file
@@ -0,0 +1,2 @@
|
||||
wget --no-check-certificate --content-disposition --max-redirect=10 --user-agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36" --referer="https://en.git.ir/" -i list.txt
|
||||
|
135
Moodle/SH/gettext.sh
Normal file
135
Moodle/SH/gettext.sh
Normal file
@@ -0,0 +1,135 @@
|
||||
#! /bin/sh
|
||||
#
|
||||
# Copyright (C) 2003, 2005-2007, 2011, 2018-2020 Free Software Foundation, Inc.
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License as published by
|
||||
# the Free Software Foundation; either version 2.1 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
# Find a way to echo strings without interpreting backslash.
|
||||
if test "X`(echo '\t') 2>/dev/null`" = 'X\t'; then
|
||||
echo='echo'
|
||||
else
|
||||
if test "X`(printf '%s\n' '\t') 2>/dev/null`" = 'X\t'; then
|
||||
echo='printf %s\n'
|
||||
else
|
||||
echo_func () {
|
||||
cat <<EOT
|
||||
$*
|
||||
EOT
|
||||
}
|
||||
echo='echo_func'
|
||||
fi
|
||||
fi
|
||||
|
||||
# This script is primarily a shell function library. In order for
|
||||
# ". gettext.sh" to find it, we install it in $PREFIX/bin (that is usually
|
||||
# contained in $PATH), rather than in some other location such as
|
||||
# $PREFIX/share/sh-scripts or $PREFIX/share/gettext. In order to not violate
|
||||
# the Filesystem Hierarchy Standard when doing so, this script is executable.
|
||||
# Therefore it needs to support the standard --help and --version.
|
||||
if test -z "${ZSH_VERSION+set}"; then
|
||||
# zsh is not POSIX compliant: By default, while ". gettext.sh" is executed,
|
||||
# it sets $0 to "gettext.sh", defeating the purpose of this test. But
|
||||
# fortunately we know that when running under zsh, this script is always
|
||||
# being sourced, not executed, because hardly anyone is crazy enough to
|
||||
# install zsh as /bin/sh.
|
||||
case "$0" in
|
||||
gettext.sh | */gettext.sh | *\\gettext.sh)
|
||||
progname=$0
|
||||
package=gettext-runtime
|
||||
version=0.21
|
||||
# func_usage
|
||||
# outputs to stdout the --help usage message.
|
||||
func_usage ()
|
||||
{
|
||||
echo "GNU gettext shell script function library version $version"
|
||||
echo "Usage: . gettext.sh"
|
||||
}
|
||||
# func_version
|
||||
# outputs to stdout the --version message.
|
||||
func_version ()
|
||||
{
|
||||
echo "$progname (GNU $package) $version"
|
||||
echo "Copyright (C) 2003-2020 Free Software Foundation, Inc.
|
||||
License GPLv2+: GNU GPL version 2 or later <https://gnu.org/licenses/gpl.html>
|
||||
This is free software: you are free to change and redistribute it.
|
||||
There is NO WARRANTY, to the extent permitted by law."
|
||||
echo "Written by" "Bruno Haible"
|
||||
}
|
||||
if test $# = 1; then
|
||||
case "$1" in
|
||||
--help | --hel | --he | --h )
|
||||
func_usage; exit 0 ;;
|
||||
--version | --versio | --versi | --vers | --ver | --ve | --v )
|
||||
func_version; exit 0 ;;
|
||||
esac
|
||||
fi
|
||||
func_usage 1>&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# eval_gettext MSGID
|
||||
# looks up the translation of MSGID and substitutes shell variables in the
|
||||
# result.
|
||||
eval_gettext () {
|
||||
gettext "$1" | (export PATH `envsubst --variables "$1"`; envsubst "$1")
|
||||
}
|
||||
|
||||
# eval_ngettext MSGID MSGID-PLURAL COUNT
|
||||
# looks up the translation of MSGID / MSGID-PLURAL for COUNT and substitutes
|
||||
# shell variables in the result.
|
||||
eval_ngettext () {
|
||||
ngettext "$1" "$2" "$3" | (export PATH `envsubst --variables "$1 $2"`; envsubst "$1 $2")
|
||||
}
|
||||
|
||||
# eval_pgettext MSGCTXT MSGID
|
||||
# looks up the translation of MSGID in the context MSGCTXT and substitutes
|
||||
# shell variables in the result.
|
||||
eval_pgettext () {
|
||||
gettext --context="$1" "$2" | (export PATH `envsubst --variables "$2"`; envsubst "$2")
|
||||
}
|
||||
|
||||
# eval_npgettext MSGCTXT MSGID MSGID-PLURAL COUNT
|
||||
# looks up the translation of MSGID / MSGID-PLURAL for COUNT in the context
|
||||
# MSGCTXT and substitutes shell variables in the result.
|
||||
eval_npgettext () {
|
||||
ngettext --context="$1" "$2" "$3" "$4" | (export PATH `envsubst --variables "$2 $3"`; envsubst "$2 $3")
|
||||
}
|
||||
|
||||
# Note: This use of envsubst is much safer than using the shell built-in 'eval'
|
||||
# would be.
|
||||
# 1) The security problem with Chinese translations that happen to use a
|
||||
# character such as \xe0\x60 is avoided.
|
||||
# 2) The security problem with malevolent translators who put in command lists
|
||||
# like "$(...)" or "`...`" is avoided.
|
||||
# 3) The translations can only refer to shell variables that are already
|
||||
# mentioned in MSGID or MSGID-PLURAL.
|
||||
#
|
||||
# Note: "export PATH" above is a dummy; this is for the case when
|
||||
# `envsubst --variables ...` returns nothing.
|
||||
#
|
||||
# Note: In eval_ngettext above, "$1 $2" means a string whose variables set is
|
||||
# the union of the variables set of "$1" and "$2".
|
||||
#
|
||||
# Note: The minimal use of backquote above ensures that trailing newlines are
|
||||
# not dropped, not from the gettext invocation and not from the value of any
|
||||
# shell variable.
|
||||
#
|
||||
# Note: Field splitting on the `envsubst --variables ...` result is desired,
|
||||
# since envsubst outputs the variables, separated by newlines. Pathname
|
||||
# wildcard expansion or tilde expansion has no effect here, since the words
|
||||
# output by "envsubst --variables ..." consist solely of alphanumeric
|
||||
# characters and underscore.
|
20
Moodle/SH/hsphnline.sh
Normal file
20
Moodle/SH/hsphnline.sh
Normal file
@@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Kiểm tra số lượng tham số đầu vào
|
||||
if [ "$#" -ne 2 ]; then
|
||||
echo "Usage: $0 <courseid> <topicid>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Gán tham số đầu vào vào biến
|
||||
COURSEID=$1
|
||||
TOPICID=$2
|
||||
|
||||
# Lấy đường dẫn thư mục hiện tại
|
||||
CURRENT_DIR=$(pwd)
|
||||
|
||||
# Chạy lệnh PHP với các tham số, sử dụng mdl.media từ thư mục hiện tại
|
||||
php /home/online.linkvn.vn/public_html/online/objpage.php "$CURRENT_DIR/mdl.media" "$COURSEID" "$TOPICID"
|
||||
|
||||
# Hiển thị thông báo hoàn tất
|
||||
echo "Command executed with mdl.media from $CURRENT_DIR, courseid=$COURSEID, and topicid=$TOPICID"
|
20
Moodle/SH/hsphonline.sh
Normal file
20
Moodle/SH/hsphonline.sh
Normal file
@@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Kiểm tra số lượng tham số đầu vào
|
||||
if [ "$#" -ne 2 ]; then
|
||||
echo "Usage: $0 <courseid> <topicid>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Gán tham số đầu vào vào biến
|
||||
COURSEID=$1
|
||||
TOPICID=$2
|
||||
|
||||
# Lấy đường dẫn thư mục hiện tại
|
||||
CURRENT_DIR=$(pwd)
|
||||
|
||||
# Chạy lệnh PHP với các tham số, sử dụng mdl.media từ thư mục hiện tại
|
||||
php /home/online.linkvn.vn/public_html/online/page.php "$CURRENT_DIR/mdl.media" "$COURSEID" "$TOPICID"
|
||||
|
||||
# Hiển thị thông báo hoàn tất
|
||||
echo "Command executed with mdl.media from $CURRENT_DIR, courseid=$COURSEID, and topicid=$TOPICID"
|
20
Moodle/SH/objonline.sh
Normal file
20
Moodle/SH/objonline.sh
Normal file
@@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Kiểm tra số lượng tham số đầu vào
|
||||
if [ "$#" -ne 2 ]; then
|
||||
echo "Usage: $0 <courseid> <topicid>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Gán tham số đầu vào vào biến
|
||||
COURSEID=$1
|
||||
TOPICID=$2
|
||||
|
||||
# Lấy đường dẫn thư mục hiện tại
|
||||
CURRENT_DIR=$(pwd)
|
||||
|
||||
# Chạy lệnh PHP với các tham số, sử dụng mdl.media từ thư mục hiện tại
|
||||
php /home/online.linkvn.vn/public_html/online/objpage.php "$CURRENT_DIR/mdl.media" "$COURSEID" "$TOPICID"
|
||||
|
||||
# Hiển thị thông báo hoàn tất
|
||||
echo "Command executed with mdl.media from $CURRENT_DIR, courseid=$COURSEID, and topicid=$TOPICID"
|
21
Moodle/SH/online.sh
Normal file
21
Moodle/SH/online.sh
Normal file
@@ -0,0 +1,21 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Kiểm tra số lượng tham số đầu vào
|
||||
if [ "$#" -ne 2 ]; then
|
||||
echo "Usage: $0 <courseid> <topicid>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Gán tham số đầu vào vào biến
|
||||
|
||||
COURSEID=$1
|
||||
TOPICID=$2
|
||||
|
||||
# Lấy đường dẫn thư mục hiện tại
|
||||
CURRENT_DIR=$(pwd)
|
||||
|
||||
# Chạy lệnh PHP với các tham số, sử dụng mdl.media từ thư mục hiện tại
|
||||
/usr/local/lsws/lsphp82/bin/php /home/online.huph.edu.vn/public_html/online/page.php "$CURRENT_DIR/mdl.media" "$COURSEID" "$TOPICID"
|
||||
|
||||
# Hiển thị thông báo hoàn tất
|
||||
echo "Command executed with mdl.media from $CURRENT_DIR, courseid=$COURSEID, and topicid=$TOPICID"
|
22
Moodle/SH/removeblank.sh
Normal file
22
Moodle/SH/removeblank.sh
Normal file
@@ -0,0 +1,22 @@
|
||||
#!/bin/bash
|
||||
|
||||
BASE_DIR="."
|
||||
|
||||
find "$BASE_DIR" -depth | while IFS= read -r path; do
|
||||
current_name=$(basename "$path")
|
||||
parent_dir=$(dirname "$path")
|
||||
|
||||
# Loại bỏ ký tự đặc biệt: # ! ' [ ] @ bằng tr + tr -d
|
||||
new_name=$(echo "$current_name" | tr -d "#!'\[\]@")
|
||||
|
||||
# Loại bỏ khoảng trắng thừa (chỉ giữ 1 dấu cách, loại bỏ cuối)
|
||||
new_name=$(echo "$new_name" | tr -s ' ' | sed 's/ *$//')
|
||||
|
||||
# Nếu tên thay đổi thì đổi tên
|
||||
if [[ "$current_name" != "$new_name" ]]; then
|
||||
mv -- "$path" "$parent_dir/$new_name"
|
||||
echo "Đã đổi tên: '$path' → '$parent_dir/$new_name'"
|
||||
fi
|
||||
done
|
||||
|
||||
echo "✅ Hoàn thành."
|
14
Moodle/SH/rename_topics.sh
Normal file
14
Moodle/SH/rename_topics.sh
Normal file
@@ -0,0 +1,14 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Lấy thư mục hiện hành nơi người dùng đang gọi lệnh
|
||||
TARGET_DIR="$(pwd)"
|
||||
|
||||
# Đổi tên các thư mục con cấp 1 theo mẫu: 1 - ABC → 1. ABC
|
||||
find "$TARGET_DIR" -mindepth 1 -maxdepth 1 -type d -regextype posix-extended -regex '.*/[0-9]+ - .+' | while read dir; do
|
||||
base=$(basename "$dir")
|
||||
newname=$(echo "$base" | sed -E 's/^([0-9]+) - (.+)$/\1. \2/')
|
||||
if [ "$base" != "$newname" ]; then
|
||||
echo "🔁 Đổi tên: $base → $newname"
|
||||
mv "$TARGET_DIR/$base" "$TARGET_DIR/$newname"
|
||||
fi
|
||||
done
|
1401
Moodle/SH/rescan-scsi-bus.sh
Normal file
1401
Moodle/SH/rescan-scsi-bus.sh
Normal file
File diff suppressed because it is too large
Load Diff
26
Moodle/SH/scan.sh
Normal file
26
Moodle/SH/scan.sh
Normal file
@@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Thư mục gốc của khóa học
|
||||
COURSE_FOLDER="$(pwd)"
|
||||
|
||||
# Tìm tất cả các thư mục con
|
||||
mapfile -t DIRS < <(find "$COURSE_FOLDER" -type d)
|
||||
|
||||
for dir in "${DIRS[@]}"; do
|
||||
relative_path="${dir#*/vod/}"
|
||||
OUTPUT_JSON="$dir/filelist.txt"
|
||||
|
||||
# Xóa tệp mdl.media cũ nếu tồn tại
|
||||
rm -f "$OUTPUT_JSON"
|
||||
|
||||
# Tìm và sắp xếp các file .pdf và .xlsx theo thứ tự tự nhiên
|
||||
mapfile -d '' -t FILES < <(find "$dir" -maxdepth 1 -type f \( -name '*.pdf' -o -name '*.xlsx' \) -print0 | sort -z -V)
|
||||
|
||||
for file in "${FILES[@]}"; do
|
||||
filename=$(basename "$file")
|
||||
vid="$relative_path/$filename"
|
||||
echo "$vid" >> "$OUTPUT_JSON"
|
||||
done
|
||||
|
||||
echo "File filelist.txt created successfully in $dir."
|
||||
done
|
41
Moodle/SH/scan1.sh
Normal file
41
Moodle/SH/scan1.sh
Normal file
@@ -0,0 +1,41 @@
|
||||
#!/bin/bash
|
||||
|
||||
COURSE_FOLDER="$(pwd)"
|
||||
|
||||
# Kiểm tra tham số
|
||||
if [ -z "$1" ]; then
|
||||
echo "Usage: $0 ext1,ext2,..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Tạo mảng extension
|
||||
IFS=',' read -ra EXT_ARRAY <<< "$1"
|
||||
|
||||
# Quét tất cả thư mục con
|
||||
mapfile -t DIRS < <(find "$COURSE_FOLDER" -type d)
|
||||
|
||||
for dir in "${DIRS[@]}"; do
|
||||
relative_path="${dir#*/vod/}"
|
||||
OUTPUT_FILE="$dir/filelist.txt"
|
||||
rm -f "$OUTPUT_FILE"
|
||||
|
||||
# Duyệt tất cả file trong thư mục
|
||||
for file in "$dir"/*; do
|
||||
[ -f "$file" ] || continue
|
||||
filename=$(basename "$file")
|
||||
ext="${filename##*.}"
|
||||
# Kiểm tra extension có trong danh sách không
|
||||
for allowed_ext in "${EXT_ARRAY[@]}"; do
|
||||
if [[ "${ext,,}" == "${allowed_ext,,}" ]]; then # ignore case
|
||||
echo "$relative_path/$filename" >> "$OUTPUT_FILE"
|
||||
break
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
# Sắp xếp tự nhiên filelist.txt
|
||||
if [ -s "$OUTPUT_FILE" ]; then
|
||||
sort -V -o "$OUTPUT_FILE" "$OUTPUT_FILE"
|
||||
echo "File filelist.txt created successfully in $dir."
|
||||
fi
|
||||
done
|
Reference in New Issue
Block a user