这是indexloc提供的服务,不要输入任何密码
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions motds/motd.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ source "@TERMUX_PREFIX@/bin/termux-setup-package-manager" || exit 1
terminal_width="$(stty size | cut -d" " -f2)"
if [[ "$terminal_width" =~ ^[0-9]+$ ]] && [ "$terminal_width" -gt 60 ]; then

motd="
motd="
\e[47m \e[0m \e[1mWelcome to Termux!\e[0m
\e[47m \e[0m \e[0;37m\e[47m .\e[0m
\e[47m \e[0m \e[47m \e[0m \e[47m \e[0m \e[1mDocs:\e[0m \e[4mhttps://termux.dev/docs\e[0m
Expand All @@ -16,11 +16,11 @@ if [[ "$terminal_width" =~ ^[0-9]+$ ]] && [ "$terminal_width" -gt 60 ]; then
\e[47m \e[0m \e[1mTermux version:\e[0m ${TERMUX_VERSION-Unknown}
"

motd_indent=" "
motd_indent=" "

else

motd="
motd="
\e[1mWelcome to Termux!\e[0m

\e[1mDocs:\e[0m \e[4mhttps://termux.dev/docs\e[0m
Expand All @@ -30,7 +30,7 @@ else
\e[1mTermux version:\e[0m ${TERMUX_VERSION-Unknown}
"

motd_indent=""
motd_indent=""
fi

motd+="
Expand All @@ -43,7 +43,7 @@ ${motd_indent}\e[1mUpgrade:\e[0m pkg upgrade

if [ "$TERMUX_APP_PACKAGE_MANAGER" = "apt" ]; then

motd+="
motd+="
${motd_indent}\e[1mSubscribing to additional repos:\e[0m
${motd_indent}\e[1mRoot:\e[0m pkg install root-repo
${motd_indent}\e[1mX11:\e[0m pkg install x11-repo
Expand Down
16 changes: 6 additions & 10 deletions scripts/chsh.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@ show_usage() {
echo "usage: chsh [-s shell]"
echo "Change the login shell."
echo
if [ "${1:-}" = "login" ]; then
echo "The shell value must be one of following and cannot be 'login':"
else
echo "The shell value must be one of following:"
fi
echo "The shell value must be one of following and cannot be 'login':"
echo " - Empty value to restore default shell."
echo " - Absolute path to shell starting with a '/'."
echo " - Relative path to shell not starting with a '/' relative to '@TERMUX_PREFIX@/bin'."
Expand All @@ -28,10 +24,6 @@ set_shell() {
exit 0
fi

if [ "$1" = "login" ]; then
show_usage "login"
exit 1
fi
mkdir -p "$HOME/.termux"

unset NEW_SHELL
Expand All @@ -44,18 +36,22 @@ set_shell() {

if ! is_executable_file "$SHELL_TARGET"; then
echo "The shell file '$SHELL_TARGET' is not an executable file." 1>&2
echo
show_usage
exit 1
fi

if [ "$SHELL_TARGET" -ef "@TERMUX_PREFIX@/bin/login" ]; then
echo "The shell file '$SHELL_TARGET' must not point to the '@TERMUX_PREFIX@/bin/login' script." 1>&2
echo
show_usage
exit 1
fi

ln -sf "$SHELL_TARGET" "$HOME/.termux/shell"
}

O=`getopt -l help -- hs: "$@"`
O=$(getopt -l help -- hs: "$@")
eval set -- "$O"
while true; do
case "$1" in
Expand Down
6 changes: 3 additions & 3 deletions scripts/dalvikvm.in
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/bin/sh

# There needs to be a folder at $ANDROID_DATA/dalvik-cache
export ANDROID_DATA=@TERMUX_PREFIX@/var/android/
mkdir -p $ANDROID_DATA/dalvik-cache
export ANDROID_DATA="@TERMUX_PREFIX@/var/android/"
mkdir -p "$ANDROID_DATA/dalvik-cache"

if [ -x /apex/com.android.art/bin/dalvikvm ]; then
DALVIKVM="/apex/com.android.art/bin/dalvikvm"
Expand All @@ -11,4 +11,4 @@ else
fi

unset LD_LIBRARY_PATH LD_PRELOAD
exec "$DALVIKVM" -Xusejit:true -Xnoimage-dex2oat -Djava.io.tmpdir=@TERMUX_PREFIX@/tmp "$@"
exec "$DALVIKVM" -Xusejit:true -Xnoimage-dex2oat -Djava.io.tmpdir="@TERMUX_PREFIX@/tmp" "$@"
12 changes: 6 additions & 6 deletions scripts/login.in
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ if tty >/dev/null 2>&1 && [ $# = 0 ] && [ ! -f ~/.hushlogin ] && [ -z "$TERMUX_H
[ ! -x ~/.termux/motd.sh ] && chmod u+x ~/.termux/motd.sh
~/.termux/motd.sh
# Default to termux-tools package provided static motd file if it exists
elif [ -f @TERMUX_PREFIX@/etc/motd ]; then
cat @TERMUX_PREFIX@/etc/motd
elif [ -f "@TERMUX_PREFIX@/etc/motd" ]; then
cat "@TERMUX_PREFIX@/etc/motd"
fi
else
# This variable shouldn't be kept set.
unset TERMUX_HUSHLOGIN
fi

# TERMUX_VERSION env variable has been exported since v0.107 and PATH was being set to following value in <0.104. Last playstore version was v0.101.
if tty >/dev/null 2>&1 && [ $# = 0 ] && [ -f @TERMUX_PREFIX@/etc/motd-playstore ] && [ -z "$TERMUX_VERSION" ] && [ "$PATH" = "@TERMUX_PREFIX@/bin:@TERMUX_PREFIX@/bin/applets" ]; then
printf '\033[0;31m'; cat @TERMUX_PREFIX@/etc/motd-playstore; printf '\033[0m'
if tty >/dev/null 2>&1 && [ $# = 0 ] && [ -f "@TERMUX_PREFIX@/etc/motd-playstore" ] && [ -z "$TERMUX_VERSION" ] && [ "$PATH" = "@TERMUX_PREFIX@/bin:@TERMUX_PREFIX@/bin/applets" ]; then
printf '\033[0;31m'; cat "@TERMUX_PREFIX@/etc/motd-playstore"; printf '\033[0m'
fi

unset SHELL
Expand Down Expand Up @@ -74,8 +74,8 @@ elif [ -f "@TERMUX_PREFIX@/lib/libtermux-exec.so" ]; then
$SHELL -c "coreutils --coreutils-prog=true" > /dev/null 2>&1 || unset LD_PRELOAD
fi

if [ -f @TERMUX_PREFIX@/etc/termux-login.sh ]; then
. @TERMUX_PREFIX@/etc/termux-login.sh
if [ -f "@TERMUX_PREFIX@/etc/termux-login.sh" ]; then
. "@TERMUX_PREFIX@/etc/termux-login.sh"
fi

if [ -n "$TERM" ]; then
Expand Down
26 changes: 7 additions & 19 deletions scripts/pkg.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ source "@TERMUX_PREFIX@/bin/termux-setup-package-manager" || exit 1
MIRROR_BASE_DIR="@TERMUX_PREFIX@/etc/termux/mirrors"

show_help() {
local cache_size
local cache_dir=""
local cache_size cache_dir=""
if [ "$TERMUX_APP_PACKAGE_MANAGER" = "apt" ]; then
cache_dir="@TERMUX_CACHE_DIR@/apt/archives"
elif [ "$TERMUX_APP_PACKAGE_MANAGER" = "pacman" ]; then
Expand Down Expand Up @@ -66,8 +65,7 @@ show_help() {
}

check_mirror() {
local mirror="${1%/}"
local timeout="${2-5}"
local mirror="${1%/}" timeout="${2-5}"

timeout "$((timeout + 1))" curl \
--head \
Expand All @@ -79,9 +77,8 @@ check_mirror() {
}

check_command() {
local command="$1"
local command="$1" errors

local errors
if ! errors="$("$@" 2>&1 1>/dev/null)"; then
echo "$errors" 1>&2
echo "Failed to run the '$command' command." 1>&2
Expand All @@ -96,13 +93,8 @@ check_command() {
fi
}

hostname() {
echo "$1" | awk -F'[/:]' '{print $4}'
}

last_modified() {
local mtime
local now
local mtime now

mtime=$(date -r "$1" '+%s')
now=$(date '+%s')
Expand Down Expand Up @@ -136,9 +128,7 @@ unset_mirror_variables() {
}

get_mirror_url() {
local -r _mirror="$1"
local -r _has_repo_x11="$2"
local -r _has_repo_root="$3"
local -r _mirror="$1" _has_repo_x11="$2" _has_repo_root="$3"

unset_mirror_variables
# shellcheck source=/dev/null
Expand Down Expand Up @@ -253,8 +243,7 @@ select_mirror() {
declare -a parallel_jobs_return_values=()

local i j mirror url job_number job_pid return_value
local total_mirrors=${#mirrors[@]}
local parallel_jobs_current_count=1
local total_mirrors=${#mirrors[@]} parallel_jobs_current_count=1

has_repo_x11="$(has_repo x11)"
has_repo_root="$(has_repo root)"
Expand Down Expand Up @@ -328,8 +317,7 @@ select_mirror() {

# Build weighted array of valid mirrors
declare -a weighted_mirrors
local total_mirror_weight=0
local weight
local total_mirror_weight=0 weight
for mirror in "${!mirrors[@]}"; do
# Check if mirror was unset in parallel check
if [ -z "${mirrors[$mirror]-}" ]; then
Expand Down
4 changes: 2 additions & 2 deletions scripts/su.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ unset LD_LIBRARY_PATH LD_PRELOAD

for p in /debug_ramdisk/su /sbin/su /system/sbin/su /system/bin/su /system/xbin/su /su/bin/su /magisk/.core/bin/su
do
if [ -x $p ]; then
if [ -x "$p" ]; then
# The su tool may require programs in PATH:
PATH=/debug_ramdisk:/sbin:/sbin/su:/su/bin:/su/xbin:/system/bin:/system/xbin \
exec $p "$@"
exec "$p" "$@"
fi
done

Expand Down
2 changes: 1 addition & 1 deletion scripts/termux-backup.in
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

set -e -u

export PREFIX=@TERMUX_PREFIX@
export PREFIX="@TERMUX_PREFIX@"

msg() {
echo "$*" >&2
Expand Down
Loading