43 lines
1.3 KiB
Bash
43 lines
1.3 KiB
Bash
#!/bin/bash
|
|
#
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
#
|
|
# Copyright (c) 2026 AMLOGIC
|
|
#
|
|
# amlenv.sh - 设置默认登录环境
|
|
|
|
# 1. 检查PATH环境变量,如果没有/sbin,则补充
|
|
if [[ ":$PATH:" != *":/sbin:"* ]]; then
|
|
export PATH="/sbin:$PATH"
|
|
echo "PATH updated: /sbin added to PATH"
|
|
fi
|
|
|
|
# 2. 主动做下resize,以使用shell窗口的自适应
|
|
# 检查是否在交互式终端中
|
|
if [ -t 1 ]; then
|
|
# 尝试resize命令
|
|
if command -v resize >/dev/null 2>&1; then
|
|
resize >/dev/null 2>&1
|
|
echo "Terminal resized for better compatibility"
|
|
elif command -v stty >/dev/null 2>&1; then
|
|
# 使用stty设置终端大小
|
|
stty rows $(tput lines) cols $(tput cols) >/dev/null 2>&1
|
|
fi
|
|
fi
|
|
|
|
# Grow rootfs to fill the eMMC partition (no-op once at max). rc.local also
|
|
# does this at boot; this branch covers the case of a login before rc.local
|
|
# has run. Skipped for non-root users — resize2fs needs CAP_SYS_ADMIN.
|
|
if [ "$EUID" = "0" ]; then
|
|
ROOT_DEV="$(findmnt -no SOURCE / 2>/dev/null)"
|
|
if [ -n "$ROOT_DEV" ] && [ -b "$ROOT_DEV" ]; then
|
|
resize2fs "$ROOT_DEV" 2>/dev/null && echo "resize2fs $ROOT_DEV done"
|
|
fi
|
|
fi
|
|
|
|
# 设置其他有用的环境变量
|
|
export EDITOR=${EDITOR:-vim}
|
|
export PAGER=${PAGER:-less}
|
|
|
|
echo "Environment setup completed"
|