mirror of
https://github.com/ronggang/transmission-web-control.git
synced 2025-04-15 22:27:09 +00:00
Update english install script to 1.2.1 .
This commit is contained in:
parent
47bb4d9f67
commit
e8cf01d397
|
@ -3,7 +3,7 @@
|
|||
ARG1="$1"
|
||||
ROOT_FOLDER=""
|
||||
SCRIPT_NAME="$0"
|
||||
SCRIPT_VERSION="1.2.0"
|
||||
SCRIPT_VERSION="1.2.1"
|
||||
VERSION=""
|
||||
WEB_FOLDER=""
|
||||
ORG_INDEX_FILE="index.original.html"
|
||||
|
@ -22,6 +22,64 @@ SKIP_SEARCH=0
|
|||
USER=`whoami`
|
||||
AUTOINSTALL=0
|
||||
|
||||
#==========================================================
|
||||
MSG_TR_WORK_FOLDER="当前 Transmission Web 目录为: "
|
||||
MSG_SPECIFIED_VERSION="您正在使用指定版本安装,版本:"
|
||||
MSG_SEARCHING_TR_FOLDER="正在搜索 Transmission Web 目录..."
|
||||
MSG_THE_SPECIFIED_DIRECTORY_DOES_NOT_EXIST="指定的目录不存在,准备进行搜索,请稍候..."
|
||||
MSG_USE_WEB_HOME="使用 TRANSMISSION_WEB_HOME 变量: $TRANSMISSION_WEB_HOME"
|
||||
MSG_AVAILABLE="可用"
|
||||
MSG_TRY_SPECIFIED_VERSION="正在尝试指定版本"
|
||||
MSG_PACK_COPYING="正在复制安装包..."
|
||||
MSG_WEB_PATH_IS_MISSING="错误 : Transmisson WEB 目录不存在,请确认是否已安装 Transmisson 。"
|
||||
MSG_PACK_IS_EXIST=" 已存在,是否重新下载?(y/n)"
|
||||
MSG_SIKP_DOWNLOAD="\n跳过下载,正在准备安装"
|
||||
MSG_DOWNLOADING="正在下载 Transmission Web Control..."
|
||||
MSG_DOWNLOAD_COMPLETE="下载完成,正在准备安装..."
|
||||
MSG_DOWNLOAD_FAILED="安装包下载失败,请重试或尝试其他版本。"
|
||||
MSG_INSTALL_COMPLETE="Transmission Web Control 安装完成!"
|
||||
MSG_PACK_EXTRACTING="正在解压安装包..."
|
||||
MSG_PACK_CLEANING_UP="正在清理安装包..."
|
||||
MSG_DONE="安装脚本执行完成。如遇到问题请查看:https://github.com/ronggang/transmission-web-control/wiki "
|
||||
MSG_SETTING_PERMISSIONS="正在设置权限,大约需要一分钟 ..."
|
||||
MSG_BEGIN="开始"
|
||||
MSG_END="结束"
|
||||
MSG_MAIN_MENU="
|
||||
欢迎使用 Transmission Web Control 中文安装脚本。
|
||||
官方帮助文档:https://github.com/ronggang/transmission-web-control/wiki
|
||||
安装脚本版本:$SCRIPT_VERSION
|
||||
|
||||
1. 安装最新的发布版本(release);
|
||||
2. 安装指定版本,可用于降级;
|
||||
3. 恢复到官方UI;
|
||||
4. 重新下载安装脚本($SCRIPT_NAME);
|
||||
5. 检测 Transmission 是否已启动;
|
||||
6. 指定安装目录;
|
||||
9. 安装最新代码库中的内容(master);
|
||||
===================
|
||||
0. 退出安装;
|
||||
|
||||
请输入对应的数字:"
|
||||
MSG_INPUT_VERSION="请输入版本号(如:1.5.1):"
|
||||
MSG_INPUT_TR_FOLDER="请输入 Transmission Web 所在的目录(不包含web,如:/usr/share/transmission):"
|
||||
MSG_SPECIFIED_FOLDER="安装目录已指定为:"
|
||||
MSG_INVALID_PATH="输入的路径无效。"
|
||||
MSG_MASTER_INSTALL_CONFIRM="最新代码可能包含未知错误,是否确认安装? (y/n): "
|
||||
MSG_FIND_WEB_FOLDER_FROM_PROCESS="正在尝试从进程中识别 Transmission Web 目录..."
|
||||
MSG_FIND_WEB_FOLDER_FROM_PROCESS_FAILED=" × 识别失败,请确认 Transmission 已启动。"
|
||||
MSG_CHECK_TR_DAEMON="正在检测 Transmission 进程..."
|
||||
MSG_CHECK_TR_DAEMON_FAILED="在系统进程中没有找到 Transmission ,请确认是否已启动。"
|
||||
MSG_TRY_START_TR="是否尝试启动 Transmission ?(y/n)"
|
||||
MSG_TR_DAEMON_IS_STARTED="Transmission 已启动。"
|
||||
MSG_REVERTING_ORIGINAL_UI="正在恢复官方UI..."
|
||||
MSG_REVERT_COMPLETE="恢复完成,在浏览器中重新访问 http://ip:9091/ 或刷新即可查看官方UI。"
|
||||
MSG_ORIGINAL_UI_IS_MISSING="官方UI不存在。"
|
||||
MSG_DOWNLOADING_INSTALL_SCRIPT="正在重新下载安装脚本..."
|
||||
MSG_INSTALL_SCRIPT_DOWNLOAD_COMPLETE="下载完成,请重新运行安装脚本。"
|
||||
MSG_INSTALL_SCRIPT_DOWNLOAD_FAILED="安装脚本下载失败!"
|
||||
MSG_NON_ROOT_USER="当前非 root 用户,无法进行安装操作。"
|
||||
#==========================================================
|
||||
|
||||
# 是否自动安装
|
||||
if [ "$ARG1" = "auto" ]; then
|
||||
AUTOINSTALL=1
|
||||
|
@ -40,7 +98,7 @@ initValues() {
|
|||
|
||||
# 判断 ROOT_FOLDER 是否为一个有效的目录,如果是则表明传递了一个有效路径
|
||||
if [ -d "$ROOT_FOLDER" ]; then
|
||||
showLog "当前 Transmission Web 目录为: $ROOT_FOLDER/web"
|
||||
showLog "$MSG_TR_WORK_FOLDER $ROOT_FOLDER/web"
|
||||
INSTALL_TYPE=3
|
||||
WEB_FOLDER="$ROOT_FOLDER/web"
|
||||
SKIP_SEARCH=1
|
||||
|
@ -57,7 +115,7 @@ initValues() {
|
|||
else
|
||||
PACK_NAME="v$VERSION.tar.gz"
|
||||
fi
|
||||
showLog "您正在使用指定版本安装,版本:$VERSION"
|
||||
showLog "$MSG_SPECIFIED_VERSION $VERSION"
|
||||
|
||||
DOWNLOAD_URL="https://github.com/ronggang/transmission-web-control/archive/$PACK_NAME"
|
||||
fi
|
||||
|
@ -82,11 +140,11 @@ main() {
|
|||
# 查找Web目录
|
||||
findWebFolder() {
|
||||
# 找出web ui 目录
|
||||
showLog "正在搜索 Transmission Web 目录..."
|
||||
showLog "$MSG_SEARCHING_TR_FOLDER"
|
||||
|
||||
# 判断 TRANSMISSION_WEB_HOME 环境变量是否被定义,如果是,直接用这个变量的值
|
||||
if [ $TRANSMISSION_WEB_HOME ]; then
|
||||
showLog "使用 TRANSMISSION_WEB_HOME 变量: $TRANSMISSION_WEB_HOME"
|
||||
showLog "$MSG_USE_WEB_HOME"
|
||||
# 判断目录是否存在,如果不存在则创建 https://github.com/ronggang/transmission-web-control/issues/167
|
||||
if [ ! -d "$TRANSMISSION_WEB_HOME" ]; then
|
||||
mkdir -p "$TRANSMISSION_WEB_HOME"
|
||||
|
@ -96,9 +154,9 @@ findWebFolder() {
|
|||
if [ -d "$ROOT_FOLDER" -a -d "$ROOT_FOLDER/web" ]; then
|
||||
WEB_FOLDER="$ROOT_FOLDER/web"
|
||||
INSTALL_TYPE=1
|
||||
showLog "$ROOT_FOLDER/web 可用."
|
||||
showLog "$ROOT_FOLDER/web $MSG_AVAILABLE."
|
||||
else
|
||||
showLog "指定的目录不存在,准备进行搜索,请稍候..."
|
||||
showLog "$MSG_THE_SPECIFIED_DIRECTORY_DOES_NOT_EXIST"
|
||||
ROOT_FOLDER=`find / -name 'web' -type d 2>/dev/null| grep 'transmission/web' | sed 's/\/web$//g'`
|
||||
|
||||
if [ -d "$ROOT_FOLDER/web" ]; then
|
||||
|
@ -113,13 +171,13 @@ findWebFolder() {
|
|||
install() {
|
||||
# 是否指定版本
|
||||
if [ "$VERSION" != "" ]; then
|
||||
showLog "正在尝试指定版本 $VERSION"
|
||||
showLog "$MSG_TRY_SPECIFIED_VERSION $VERSION"
|
||||
# 下载安装包
|
||||
download
|
||||
# 解压安装包
|
||||
unpack
|
||||
|
||||
showLog "正在复制安装包..."
|
||||
showLog "$MSG_PACK_COPYING"
|
||||
# 复制文件到
|
||||
cp -r "$TMP_FOLDER/transmission-web-control-$VERSION/src/." "$WEB_FOLDER/"
|
||||
# 设置权限
|
||||
|
@ -137,7 +195,7 @@ install() {
|
|||
# 解压缩包
|
||||
unpack "web"
|
||||
|
||||
showLog "正在复制安装包..."
|
||||
showLog "$MSG_PACK_COPYING"
|
||||
# 复制文件到
|
||||
cp -r web "$ROOT_FOLDER"
|
||||
# 设置权限
|
||||
|
@ -158,7 +216,7 @@ install() {
|
|||
else
|
||||
echo "##############################################"
|
||||
echo "#"
|
||||
echo "# 错误 : Transmisson WEB 目录不存在,请确认是否已安装 Transmisson 。"
|
||||
echo "# $MSG_WEB_PATH_IS_MISSING"
|
||||
echo "#"
|
||||
echo "##############################################"
|
||||
fi
|
||||
|
@ -171,7 +229,7 @@ download() {
|
|||
# 判断安装包文件是否已存在
|
||||
if [ -f "$PACK_NAME" ]; then
|
||||
if [ $AUTOINSTALL = 0 ]; then
|
||||
echo -n "\n$PACK_NAME 已存在,是否重新下载?(y/n)"
|
||||
echo -n "\n$PACK_NAME $MSG_PACK_IS_EXIST"
|
||||
read flag
|
||||
else
|
||||
flag="y"
|
||||
|
@ -180,19 +238,19 @@ download() {
|
|||
if [ "$flag" = "y" -o "$flag" = "Y" ] ; then
|
||||
rm "$PACK_NAME"
|
||||
else
|
||||
showLog "\n跳过下载,正在准备安装"
|
||||
showLog "$MSG_SIKP_DOWNLOAD"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
showLog "正在下载 Transmission Web Control..."
|
||||
showLog "$MSG_DOWNLOADING"
|
||||
echo ""
|
||||
wget "$DOWNLOAD_URL" --no-check-certificate
|
||||
# 判断是否下载成功
|
||||
if [ $? -eq 0 ]; then
|
||||
showLog "下载完成,正在准备安装..."
|
||||
showLog "$MSG_DOWNLOAD_COMPLETE"
|
||||
return 0
|
||||
else
|
||||
showLog "安装包下载失败,请重试或尝试其他版本。"
|
||||
showLog "$MSG_DOWNLOAD_FAILED"
|
||||
end
|
||||
exit 1
|
||||
fi
|
||||
|
@ -200,7 +258,7 @@ download() {
|
|||
|
||||
# 安装完成
|
||||
installed() {
|
||||
showLog "Transmission Web Control 安装完成!"
|
||||
showLog "$MSG_INSTALL_COMPLETE"
|
||||
}
|
||||
|
||||
# 输出日志
|
||||
|
@ -218,7 +276,7 @@ showLog() {
|
|||
|
||||
# 解压安装包
|
||||
unpack() {
|
||||
showLog "正在解压安装包..."
|
||||
showLog "$MSG_PACK_EXTRACTING"
|
||||
if [ "$1" != "" ]; then
|
||||
tar -xzf "$PACK_NAME" -C "$1"
|
||||
else
|
||||
|
@ -237,7 +295,7 @@ unpack() {
|
|||
|
||||
# 清除工作
|
||||
clear() {
|
||||
showLog "正在清理安装包..."
|
||||
showLog "$MSG_PACK_CLEANING_UP"
|
||||
if [ -f "$PACK_NAME" ]; then
|
||||
# 删除安装包
|
||||
rm "$PACK_NAME"
|
||||
|
@ -248,14 +306,14 @@ clear() {
|
|||
rm -rf "$TMP_FOLDER"
|
||||
fi
|
||||
|
||||
showLog "安装脚本执行完成。如遇到问题请查看:https://github.com/ronggang/transmission-web-control/wiki "
|
||||
showLog "$MSG_DONE"
|
||||
end
|
||||
}
|
||||
|
||||
# 设置权限
|
||||
setPermissions() {
|
||||
folder="$1"
|
||||
showLog "正在设置权限,大约需要一分钟 ..."
|
||||
showLog "$MSG_SETTING_PERMISSIONS"
|
||||
# 设置权限
|
||||
find "$folder" -type d -exec chmod o+rx {} \;
|
||||
find "$folder" -type f -exec chmod o+r {} \;
|
||||
|
@ -264,35 +322,19 @@ setPermissions() {
|
|||
# 开始
|
||||
begin() {
|
||||
echo ""
|
||||
showLog "== 开始 =="
|
||||
showLog "== $MSG_BEGIN =="
|
||||
showLog ""
|
||||
}
|
||||
|
||||
# 结束
|
||||
end() {
|
||||
showLog "== 结束 =="
|
||||
showLog "== $MSG_END =="
|
||||
echo ""
|
||||
}
|
||||
|
||||
# 显示主菜单
|
||||
showMainMenu() {
|
||||
msg="
|
||||
欢迎使用 Transmission Web Control 中文安装脚本。
|
||||
官方帮助文档:https://github.com/ronggang/transmission-web-control/wiki
|
||||
安装脚本版本:$SCRIPT_VERSION
|
||||
|
||||
1. 安装最新的发布版本(release);
|
||||
2. 安装指定版本,可用于降级;
|
||||
3. 恢复到官方UI;
|
||||
4. 重新下载安装脚本($SCRIPT_NAME);
|
||||
5. 检测 Transmission 是否已启动;
|
||||
6. 指定安装目录;
|
||||
9. 安装最新代码库中的内容(master);
|
||||
===================
|
||||
0. 退出安装;
|
||||
|
||||
请输入对应的数字:"
|
||||
echo -n "$msg"
|
||||
echo -n "$MSG_MAIN_MENU"
|
||||
read flag
|
||||
echo ""
|
||||
case $flag in
|
||||
|
@ -301,7 +343,7 @@ showMainMenu() {
|
|||
;;
|
||||
|
||||
2)
|
||||
echo -n "请输入版本号(如:1.5.1):"
|
||||
echo -n "$MSG_INPUT_VERSION"
|
||||
read VERSION
|
||||
main
|
||||
;;
|
||||
|
@ -319,13 +361,13 @@ showMainMenu() {
|
|||
;;
|
||||
|
||||
6)
|
||||
echo -n "请输入 Transmission Web 所在的目录(不包含web,如:/usr/share/transmission):"
|
||||
echo -n "$MSG_INPUT_TR_FOLDER"
|
||||
read input
|
||||
if [ -d "$input/web" ]; then
|
||||
ROOT_FOLDER="$input"
|
||||
showLog "安装目录已指定为:$input/web"
|
||||
showLog "$MSG_SPECIFIED_FOLDER $input/web"
|
||||
else
|
||||
showLog "输入的路径无效。"
|
||||
showLog "$MSG_INVALID_PATH"
|
||||
fi
|
||||
sleep 2
|
||||
showMainMenu
|
||||
|
@ -333,7 +375,7 @@ showMainMenu() {
|
|||
|
||||
# 下载最新的代码
|
||||
9)
|
||||
echo -n "最新代码可能包含未知错误,是否确认安装? (y/n): "
|
||||
echo -n "$MSG_MASTER_INSTALL_CONFIRM"
|
||||
read input
|
||||
if [ "$input" = "y" -o "$input" = "Y" ]; then
|
||||
VERSION="master"
|
||||
|
@ -343,7 +385,7 @@ showMainMenu() {
|
|||
fi
|
||||
;;
|
||||
*)
|
||||
showLog "结束"
|
||||
showLog "$MSG_END"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
@ -359,7 +401,7 @@ getTransmissionPath() {
|
|||
fi
|
||||
|
||||
if [ ! -d "$ROOT_FOLDER" ]; then
|
||||
showLog "正在尝试从进程中识别 Transmission Web 目录..." "n"
|
||||
showLog "$MSG_FIND_WEB_FOLDER_FROM_PROCESS" "n"
|
||||
infos=`ps -ef | awk '/[t]ransmission-da/{print $8}'`
|
||||
if [ "$infos" != "" ]; then
|
||||
echo " √"
|
||||
|
@ -370,24 +412,24 @@ getTransmissionPath() {
|
|||
ROOT_FOLDER=$path
|
||||
fi
|
||||
else
|
||||
echo " × 识别失败,请确认 Transmission 已启动。"
|
||||
echo "$MSG_FIND_WEB_FOLDER_FROM_PROCESS_FAILED"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# 检测 Transmission 进程是否存在
|
||||
checkTransmissionDaemon() {
|
||||
showLog "正在检测 Transmission 进程..."
|
||||
showLog "$MSG_CHECK_TR_DAEMON"
|
||||
ps -C transmission-daemon
|
||||
if [ $? -ne 0 ]; then
|
||||
showLog "在系统进程中没有找到 Transmission ,请确认是否已启动。"
|
||||
echo -n "是否尝试启动 Transmission ?(y/n)"
|
||||
showLog "$MSG_CHECK_TR_DAEMON_FAILED"
|
||||
echo -n "$MSG_TRY_START_TR"
|
||||
read input
|
||||
if [ "$input" = "y" -o "$input" = "Y" ] ; then
|
||||
service transmission-daemon start
|
||||
fi
|
||||
else
|
||||
showLog "Transmission 已启动。"
|
||||
showLog "$MSG_TR_DAEMON_IS_STARTED"
|
||||
fi
|
||||
sleep 2
|
||||
showMainMenu
|
||||
|
@ -398,7 +440,7 @@ revertOriginalUI() {
|
|||
initValues
|
||||
# 判断是否有官方的UI存在
|
||||
if [ -f "$WEB_FOLDER/$ORG_INDEX_FILE" ]; then
|
||||
showLog "正在恢复官方UI..."
|
||||
showLog "$MSG_REVERTING_ORIGINAL_UI"
|
||||
# 清除原来的内容
|
||||
if [ -d "$WEB_FOLDER/tr-web-control" ]; then
|
||||
rm -rf "$WEB_FOLDER/tr-web-control"
|
||||
|
@ -406,14 +448,14 @@ revertOriginalUI() {
|
|||
rm "$WEB_FOLDER/index.html"
|
||||
rm "$WEB_FOLDER/index.mobile.html"
|
||||
mv "$WEB_FOLDER/$ORG_INDEX_FILE" "$WEB_FOLDER/$INDEX_FILE"
|
||||
showLog "恢复完成,在浏览器中重新访问 http://ip:9091/ 或刷新即可查看官方UI。"
|
||||
showLog "$MSG_REVERT_COMPLETE"
|
||||
else
|
||||
showLog "Transmission Web Control 目录不存在。"
|
||||
showLog "$MSG_WEB_PATH_IS_MISSING"
|
||||
sleep 2
|
||||
showMainMenu
|
||||
fi
|
||||
else
|
||||
showLog "官方UI不存在。"
|
||||
showLog "$MSG_ORIGINAL_UI_IS_MISSING"
|
||||
sleep 2
|
||||
showMainMenu
|
||||
fi
|
||||
|
@ -424,20 +466,20 @@ downloadInstallScript() {
|
|||
if [ -f "$SCRIPT_NAME" ]; then
|
||||
rm "$SCRIPT_NAME"
|
||||
fi
|
||||
showLog "正在重新下载安装脚本..."
|
||||
showLog "$MSG_DOWNLOADING_INSTALL_SCRIPT"
|
||||
wget "https://github.com/ronggang/transmission-web-control/raw/master/release/$SCRIPT_NAME" --no-check-certificate
|
||||
# 判断是否下载成功
|
||||
if [ $? -eq 0 ]; then
|
||||
showLog "下载完成,请重新运行安装脚本。"
|
||||
showLog "$MSG_INSTALL_SCRIPT_DOWNLOAD_COMPLETE"
|
||||
else
|
||||
showLog "安装脚本下载失败!"
|
||||
showLog "$MSG_INSTALL_SCRIPT_DOWNLOAD_FAILED"
|
||||
sleep 2
|
||||
showMainMenu
|
||||
fi
|
||||
}
|
||||
|
||||
if [ "$USER" != 'root' ]; then
|
||||
showLog "当前非 root 用户,无法进行安装操作。"
|
||||
showLog "$MSG_NON_ROOT_USER"
|
||||
exit -1
|
||||
fi
|
||||
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
#!/bin/sh
|
||||
# 获取第一个参数做为目录
|
||||
ROOT_FOLDER="$1"
|
||||
#!/bin/bash
|
||||
# 获取第一个参数
|
||||
ARG1="$1"
|
||||
ROOT_FOLDER=""
|
||||
SCRIPT_NAME="$0"
|
||||
SCRIPT_VERSION="1.1.0"
|
||||
SCRIPT_VERSION="1.2.1"
|
||||
VERSION=""
|
||||
WEB_FOLDER=""
|
||||
ORG_INDEX_FILE="index.original.html"
|
||||
|
@ -18,6 +19,73 @@ DOWNLOAD_URL="$WEB_HOST$PACK_NAME"
|
|||
# 3 用户指定参数做为目录,如 sh install-tr-control.sh /usr/local/transmission/share/transmission
|
||||
INSTALL_TYPE=-1
|
||||
SKIP_SEARCH=0
|
||||
USER=`whoami`
|
||||
AUTOINSTALL=0
|
||||
|
||||
#==========================================================
|
||||
MSG_TR_WORK_FOLDER="Transmission Web Path: "
|
||||
MSG_SPECIFIED_VERSION="You are using the specified version to install, version:"
|
||||
MSG_SEARCHING_TR_FOLDER="Searching Transmission Web Folder..."
|
||||
MSG_THE_SPECIFIED_DIRECTORY_DOES_NOT_EXIST="Folder not found. Will search the entire /. This will take a while..."
|
||||
MSG_USE_WEB_HOME="Use TRANSMISSION_WEB_HOME Variable: $TRANSMISSION_WEB_HOME"
|
||||
MSG_AVAILABLE="Available"
|
||||
MSG_TRY_SPECIFIED_VERSION="Attempting to specify version: "
|
||||
MSG_PACK_COPYING="Copying installation package..."
|
||||
MSG_WEB_PATH_IS_MISSING="ERROR : Transmisson WEB UI Folder is missing, Please confirm Transmisson is installed."
|
||||
MSG_PACK_IS_EXIST=" Already exist, whether to download again? (y/n)"
|
||||
MSG_SIKP_DOWNLOAD="\nSkip download, preparing to install"
|
||||
MSG_DOWNLOADING="Transmission Web Control Is Downloading..."
|
||||
MSG_DOWNLOAD_COMPLETE="Download completed, ready to install..."
|
||||
MSG_DOWNLOAD_FAILED="The installation package failed to download. Please try again or try another version."
|
||||
MSG_INSTALL_COMPLETE="Transmission Web Control Installation Completed!"
|
||||
MSG_PACK_EXTRACTING="Extracting installation package..."
|
||||
MSG_PACK_CLEANING_UP="Cleaning up the installation package..."
|
||||
MSG_DONE="Installation completed. Installation problems see:https://github.com/ronggang/transmission-web-control/wiki "
|
||||
MSG_SETTING_PERMISSIONS="Setting permissions, It takes about one minute ..."
|
||||
MSG_BEGIN="BEGIN"
|
||||
MSG_END="END"
|
||||
MSG_MAIN_MENU="
|
||||
Welcome to the Transmission Web Control Installation Script.
|
||||
Official help documentation: https://github.com/ronggang/transmission-web-control/wiki
|
||||
Installation script version: $SCRIPT_VERSION
|
||||
|
||||
1. Install the latest release.
|
||||
2. Install the specified version.
|
||||
3. Revert to the official UI.
|
||||
4. Re-download the installation script.
|
||||
5. Check if Transmission is started.
|
||||
6. Input the Transmission Web directory.
|
||||
9. Installing from 'master' Repository.
|
||||
===================
|
||||
0. Exit the installation;
|
||||
|
||||
Please enter the corresponding number: "
|
||||
MSG_INPUT_VERSION="Please enter the version number (e.g: 1.5.1):"
|
||||
MSG_INPUT_TR_FOLDER="Please enter the directory where the Transmission Web is located (without 'web', e.g /usr/share/transmission): "
|
||||
MSG_SPECIFIED_FOLDER="The installation directory is specified as: "
|
||||
MSG_INVALID_PATH="The input path is invalid."
|
||||
MSG_MASTER_INSTALL_CONFIRM="Do you confirm the installation? (y/n): "
|
||||
MSG_FIND_WEB_FOLDER_FROM_PROCESS="Attempting to identify transmission Web directory from process..."
|
||||
MSG_FIND_WEB_FOLDER_FROM_PROCESS_FAILED=" × Recognition failed, please confirm that transmission has started."
|
||||
MSG_CHECK_TR_DAEMON="Detecting the Transmission process..."
|
||||
MSG_CHECK_TR_DAEMON_FAILED="No Transmission was found in the system process. Please confirm that it is started."
|
||||
MSG_TRY_START_TR="Do you want to try to start transmission-daemon? (y/n) "
|
||||
MSG_TR_DAEMON_IS_STARTED="Transmission Is Started."
|
||||
MSG_REVERTING_ORIGINAL_UI="Restoring the official UI..."
|
||||
MSG_REVERT_COMPLETE="Restore complete, please re-enter http://ip:9091/ or refresh in the browser to view the official UI."
|
||||
MSG_ORIGINAL_UI_IS_MISSING="The official UI does not exist."
|
||||
MSG_DOWNLOADING_INSTALL_SCRIPT="Re-downloading the installation script..."
|
||||
MSG_INSTALL_SCRIPT_DOWNLOAD_COMPLETE="The download is complete. Please re-run the installation script."
|
||||
MSG_INSTALL_SCRIPT_DOWNLOAD_FAILED="Installation Script Download failed!"
|
||||
MSG_NON_ROOT_USER="Please use the root user to install."
|
||||
#==========================================================
|
||||
|
||||
# 是否自动安装
|
||||
if [ "$ARG1" = "auto" ]; then
|
||||
AUTOINSTALL=1
|
||||
else
|
||||
ROOT_FOLDER=$ARG1
|
||||
fi
|
||||
|
||||
initValues() {
|
||||
# 判断临时目录是否存在,不存在则创建
|
||||
|
@ -25,9 +93,12 @@ initValues() {
|
|||
mkdir -p "$TMP_FOLDER"
|
||||
fi
|
||||
|
||||
# 获取 Transmission 目录
|
||||
getTransmissionPath
|
||||
|
||||
# 判断 ROOT_FOLDER 是否为一个有效的目录,如果是则表明传递了一个有效路径
|
||||
if [ -d "$ROOT_FOLDER" ]; then
|
||||
showLog "Use parameters: $ROOT_FOLDER"
|
||||
showLog "$MSG_TR_WORK_FOLDER $ROOT_FOLDER/web"
|
||||
INSTALL_TYPE=3
|
||||
WEB_FOLDER="$ROOT_FOLDER/web"
|
||||
SKIP_SEARCH=1
|
||||
|
@ -35,8 +106,17 @@ initValues() {
|
|||
|
||||
# 判断是否指定了版本
|
||||
if [ "$VERSION" != "" ]; then
|
||||
showLog "You are using the specified version to install, version: $VERSION"
|
||||
PACK_NAME="v$VERSION.tar.gz"
|
||||
# 是否指定了 v
|
||||
if [ "$VERSION" = "master" ]; then
|
||||
PACK_NAME="$VERSION.tar.gz"
|
||||
elif [ ${VERSION:0:1} = "v" ]; then
|
||||
PACK_NAME="$VERSION.tar.gz"
|
||||
VERSION=${VERSION:1}
|
||||
else
|
||||
PACK_NAME="v$VERSION.tar.gz"
|
||||
fi
|
||||
showLog "$MSG_SPECIFIED_VERSION $VERSION"
|
||||
|
||||
DOWNLOAD_URL="https://github.com/ronggang/transmission-web-control/archive/$PACK_NAME"
|
||||
fi
|
||||
|
||||
|
@ -60,31 +140,23 @@ main() {
|
|||
# 查找Web目录
|
||||
findWebFolder() {
|
||||
# 找出web ui 目录
|
||||
showLog "Searching Transmission Web Folder..."
|
||||
# 指定一次当前系统的默认目录
|
||||
# 用户如知道自己的 Transmission Web 所在的目录,直接修改这个值,以避免搜索所有目录
|
||||
ROOT_FOLDER="/usr/local/transmission/share/transmission"
|
||||
# Fedora 或 Debian 发行版的默认 ROOT_FOLDER 目录
|
||||
if [ -f /etc/fedora-release ] || [ -f "/etc/debian_version" ]; then
|
||||
ROOT_FOLDER="/usr/share/transmission"
|
||||
fi
|
||||
showLog "$MSG_SEARCHING_TR_FOLDER"
|
||||
|
||||
# 判断 TRANSMISSION_WEB_HOME 环境变量是否被定义,如果是,直接用这个变量的值
|
||||
if [ $TRANSMISSION_WEB_HOME ]; then
|
||||
showLog "Use TRANSMISSION_WEB_HOME : $TRANSMISSION_WEB_HOME"
|
||||
showLog "$MSG_USE_WEB_HOME"
|
||||
# 判断目录是否存在,如果不存在则创建 https://github.com/ronggang/transmission-web-control/issues/167
|
||||
if [ ! -d "$TRANSMISSION_WEB_HOME" ]; then
|
||||
mkdir -p "$TRANSMISSION_WEB_HOME"
|
||||
fi
|
||||
INSTALL_TYPE=2
|
||||
else
|
||||
showLog "Looking for folder $ROOT_FOLDER/web"
|
||||
if [ -d "$ROOT_FOLDER/web" ]; then
|
||||
if [ -d "$ROOT_FOLDER" -a -d "$ROOT_FOLDER/web" ]; then
|
||||
WEB_FOLDER="$ROOT_FOLDER/web"
|
||||
INSTALL_TYPE=1
|
||||
showLog "Folder found. Using it."
|
||||
showLog "$ROOT_FOLDER/web $MSG_AVAILABLE."
|
||||
else
|
||||
showLog "Folder not found. Will search the entire /. This will take a while..."
|
||||
showLog "$MSG_THE_SPECIFIED_DIRECTORY_DOES_NOT_EXIST"
|
||||
ROOT_FOLDER=`find / -name 'web' -type d 2>/dev/null| grep 'transmission/web' | sed 's/\/web$//g'`
|
||||
|
||||
if [ -d "$ROOT_FOLDER/web" ]; then
|
||||
|
@ -99,13 +171,13 @@ findWebFolder() {
|
|||
install() {
|
||||
# 是否指定版本
|
||||
if [ "$VERSION" != "" ]; then
|
||||
showLog "Attempting to specify version: $VERSION"
|
||||
# 下载最新的安装包
|
||||
showLog "$MSG_TRY_SPECIFIED_VERSION $VERSION"
|
||||
# 下载安装包
|
||||
download
|
||||
#
|
||||
# 解压安装包
|
||||
unpack
|
||||
|
||||
showLog "Copying installation package..."
|
||||
showLog "$MSG_PACK_COPYING"
|
||||
# 复制文件到
|
||||
cp -r "$TMP_FOLDER/transmission-web-control-$VERSION/src/." "$WEB_FOLDER/"
|
||||
# 设置权限
|
||||
|
@ -115,7 +187,7 @@ install() {
|
|||
|
||||
# 如果目录存在,则进行下载和更新动作
|
||||
elif [ $INSTALL_TYPE = 1 -o $INSTALL_TYPE = 3 ]; then
|
||||
# 下载最新的安装包
|
||||
# 下载安装包
|
||||
download
|
||||
# 创建web文件夹,从 20171014 之后,打包文件不包含web目录,直接打包为src下所有文件
|
||||
mkdir web
|
||||
|
@ -123,7 +195,7 @@ install() {
|
|||
# 解压缩包
|
||||
unpack "web"
|
||||
|
||||
showLog "Copying installation package..."
|
||||
showLog "$MSG_PACK_COPYING"
|
||||
# 复制文件到
|
||||
cp -r web "$ROOT_FOLDER"
|
||||
# 设置权限
|
||||
|
@ -132,7 +204,7 @@ install() {
|
|||
installed
|
||||
|
||||
elif [ $INSTALL_TYPE = 2 ]; then
|
||||
# 下载最新的安装包
|
||||
# 下载安装包
|
||||
download
|
||||
# 解压缩包
|
||||
unpack "$TRANSMISSION_WEB_HOME"
|
||||
|
@ -144,35 +216,41 @@ install() {
|
|||
else
|
||||
echo "##############################################"
|
||||
echo "#"
|
||||
echo "# ERROR : Transmisson WEB UI Folder is missing, Please confirm Transmisson is installed."
|
||||
echo "# $MSG_WEB_PATH_IS_MISSING"
|
||||
echo "#"
|
||||
echo "##############################################"
|
||||
fi
|
||||
}
|
||||
|
||||
# 下载最新的安装包
|
||||
# 下载安装包
|
||||
download() {
|
||||
# 切换到临时目录
|
||||
cd "$TMP_FOLDER"
|
||||
# 判断安装包文件是否已存在
|
||||
if [ -f "$PACK_NAME" ]; then
|
||||
echo -n "\n$PACK_NAME Already exist, whether to download again? (y/n)"
|
||||
read flag
|
||||
if [ $AUTOINSTALL = 0 ]; then
|
||||
echo -n "\n$PACK_NAME $MSG_PACK_IS_EXIST"
|
||||
read flag
|
||||
else
|
||||
flag="y"
|
||||
fi
|
||||
|
||||
if [ "$flag" = "y" -o "$flag" = "Y" ] ; then
|
||||
rm "$PACK_NAME"
|
||||
else
|
||||
showLog "\nSkip download, preparing to install"
|
||||
showLog "$MSG_SIKP_DOWNLOAD"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
showLog "Downloading Transmission Web Control...\n"
|
||||
showLog "$MSG_DOWNLOADING"
|
||||
echo ""
|
||||
wget "$DOWNLOAD_URL" --no-check-certificate
|
||||
# 判断是否下载成功
|
||||
if [ $? -eq 0 ]; then
|
||||
showLog "Download completed, ready to install..."
|
||||
showLog "$MSG_DOWNLOAD_COMPLETE"
|
||||
return 0
|
||||
else
|
||||
showLog "The installation package failed to download. Please try again or try another version."
|
||||
showLog "$MSG_DOWNLOAD_FAILED"
|
||||
end
|
||||
exit 1
|
||||
fi
|
||||
|
@ -180,18 +258,25 @@ download() {
|
|||
|
||||
# 安装完成
|
||||
installed() {
|
||||
showLog "Transmission Web Control Installation Completed!"
|
||||
showLog "$MSG_INSTALL_COMPLETE"
|
||||
}
|
||||
|
||||
# 输出日志
|
||||
showLog() {
|
||||
TIME=`date "+%Y-%m-%d %H:%M:%S"`
|
||||
echo "<< $TIME >> $1"
|
||||
|
||||
case $2 in
|
||||
"n")
|
||||
echo -n "<< $TIME >> $1" ;;
|
||||
*)
|
||||
echo "<< $TIME >> $1" ;;
|
||||
esac
|
||||
|
||||
}
|
||||
|
||||
# 解压安装包
|
||||
unpack() {
|
||||
showLog "Decompressing installation package..."
|
||||
showLog "$MSG_PACK_EXTRACTING"
|
||||
if [ "$1" != "" ]; then
|
||||
tar -xzf "$PACK_NAME" -C "$1"
|
||||
else
|
||||
|
@ -210,7 +295,7 @@ unpack() {
|
|||
|
||||
# 清除工作
|
||||
clear() {
|
||||
showLog "Cleaning up the installation package..."
|
||||
showLog "$MSG_PACK_CLEANING_UP"
|
||||
if [ -f "$PACK_NAME" ]; then
|
||||
# 删除安装包
|
||||
rm "$PACK_NAME"
|
||||
|
@ -221,14 +306,14 @@ clear() {
|
|||
rm -rf "$TMP_FOLDER"
|
||||
fi
|
||||
|
||||
showLog "Installation completed. Installation problems see: https://github.com/ronggang/transmission-web-control/wiki "
|
||||
showLog "$MSG_DONE"
|
||||
end
|
||||
}
|
||||
|
||||
# 设置权限
|
||||
setPermissions() {
|
||||
folder="$1"
|
||||
showLog "Setting permissions, It takes about one minute ..."
|
||||
showLog "$MSG_SETTING_PERMISSIONS"
|
||||
# 设置权限
|
||||
find "$folder" -type d -exec chmod o+rx {} \;
|
||||
find "$folder" -type f -exec chmod o+r {} \;
|
||||
|
@ -237,40 +322,28 @@ setPermissions() {
|
|||
# 开始
|
||||
begin() {
|
||||
echo ""
|
||||
showLog "== Beginning =="
|
||||
showLog "== $MSG_BEGIN =="
|
||||
showLog ""
|
||||
}
|
||||
|
||||
# 结束
|
||||
end() {
|
||||
showLog "== End ==\n"
|
||||
showLog "== $MSG_END =="
|
||||
echo ""
|
||||
}
|
||||
|
||||
# 显示主菜单
|
||||
showMainMenu() {
|
||||
msg="
|
||||
Welcome to the Transmission Web Control Installation Script.
|
||||
Official help documentation: https://github.com/ronggang/transmission-web-control/wiki
|
||||
Installation script version: $SCRIPT_VERSION\n
|
||||
1. Install the latest release;
|
||||
2. Install the specified version;
|
||||
3. Revert to the official UI;
|
||||
4. Re-download the installation script;
|
||||
5. Check if Transmission is started;
|
||||
6. Input the Transmission Web directory;
|
||||
===================
|
||||
0. Exit the installation;\n
|
||||
Please enter the corresponding number: "
|
||||
echo -n "$msg"
|
||||
echo -n "$MSG_MAIN_MENU"
|
||||
read flag
|
||||
echo "\n"
|
||||
echo ""
|
||||
case $flag in
|
||||
1)
|
||||
main
|
||||
;;
|
||||
|
||||
2)
|
||||
echo -n "Please enter the version number (do not include 'v', such as: 1.5.1): "
|
||||
echo -n "$MSG_INPUT_VERSION"
|
||||
read VERSION
|
||||
main
|
||||
;;
|
||||
|
@ -288,32 +361,75 @@ showMainMenu() {
|
|||
;;
|
||||
|
||||
6)
|
||||
echo -n "Please enter the directory where the Transmission Web is located (without 'web', eg /usr/share/transmission): "
|
||||
echo -n "$MSG_INPUT_TR_FOLDER"
|
||||
read input
|
||||
if [ -d "$input/web" ]; then
|
||||
ROOT_FOLDER="$input"
|
||||
showLog "The installation directory is specified as: $input/web"
|
||||
showLog "$MSG_SPECIFIED_FOLDER $input/web"
|
||||
else
|
||||
showLog "The input path is invalid."
|
||||
showLog "$MSG_INVALID_PATH"
|
||||
fi
|
||||
sleep 2
|
||||
showMainMenu
|
||||
;;
|
||||
|
||||
|
||||
# 下载最新的代码
|
||||
9)
|
||||
echo -n "$MSG_MASTER_INSTALL_CONFIRM"
|
||||
read input
|
||||
if [ "$input" = "y" -o "$input" = "Y" ]; then
|
||||
VERSION="master"
|
||||
main
|
||||
else
|
||||
showMainMenu
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
showLog "END"
|
||||
showLog "$MSG_END"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# 获取Tr所在的目录
|
||||
getTransmissionPath() {
|
||||
# 指定一次当前系统的默认目录
|
||||
# 用户如知道自己的 Transmission Web 所在的目录,直接修改这个值,以避免搜索所有目录
|
||||
# ROOT_FOLDER="/usr/local/transmission/share/transmission"
|
||||
# Fedora 或 Debian 发行版的默认 ROOT_FOLDER 目录
|
||||
if [ -f "/etc/fedora-release" ] || [ -f "/etc/debian_version" ]; then
|
||||
ROOT_FOLDER="/usr/share/transmission"
|
||||
fi
|
||||
|
||||
if [ ! -d "$ROOT_FOLDER" ]; then
|
||||
showLog "$MSG_FIND_WEB_FOLDER_FROM_PROCESS" "n"
|
||||
infos=`ps -ef | awk '/[t]ransmission-da/{print $8}'`
|
||||
if [ "$infos" != "" ]; then
|
||||
echo " √"
|
||||
search="bin/transmission-daemon"
|
||||
replace="share/transmission"
|
||||
path=${infos//$search/$replace}
|
||||
if [ -d "$path" ]; then
|
||||
ROOT_FOLDER=$path
|
||||
fi
|
||||
else
|
||||
echo "$MSG_FIND_WEB_FOLDER_FROM_PROCESS_FAILED"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# 检测 Transmission 进程是否存在
|
||||
checkTransmissionDaemon() {
|
||||
showLog "Detecting the Transmission process..."
|
||||
showLog "$MSG_CHECK_TR_DAEMON"
|
||||
ps -C transmission-daemon
|
||||
if [ $? -ne 0 ]; then
|
||||
showLog "No Transmission was found in the system process. Please confirm that it is started."
|
||||
showLog "$MSG_CHECK_TR_DAEMON_FAILED"
|
||||
echo -n "$MSG_TRY_START_TR"
|
||||
read input
|
||||
if [ "$input" = "y" -o "$input" = "Y" ] ; then
|
||||
service transmission-daemon start
|
||||
fi
|
||||
else
|
||||
showLog "Transmission is running."
|
||||
showLog "$MSG_TR_DAEMON_IS_STARTED"
|
||||
fi
|
||||
sleep 2
|
||||
showMainMenu
|
||||
|
@ -324,7 +440,7 @@ revertOriginalUI() {
|
|||
initValues
|
||||
# 判断是否有官方的UI存在
|
||||
if [ -f "$WEB_FOLDER/$ORG_INDEX_FILE" ]; then
|
||||
showLog "Restoring the official UI..."
|
||||
showLog "$MSG_REVERTING_ORIGINAL_UI"
|
||||
# 清除原来的内容
|
||||
if [ -d "$WEB_FOLDER/tr-web-control" ]; then
|
||||
rm -rf "$WEB_FOLDER/tr-web-control"
|
||||
|
@ -332,14 +448,14 @@ revertOriginalUI() {
|
|||
rm "$WEB_FOLDER/index.html"
|
||||
rm "$WEB_FOLDER/index.mobile.html"
|
||||
mv "$WEB_FOLDER/$ORG_INDEX_FILE" "$WEB_FOLDER/$INDEX_FILE"
|
||||
showLog "After the recovery is complete, visit http://ip:9091/ again in the browser to see the official UI."
|
||||
showLog "$MSG_REVERT_COMPLETE"
|
||||
else
|
||||
showLog "Transmission Web Control Directory does not exist."
|
||||
showLog "$MSG_WEB_PATH_IS_MISSING"
|
||||
sleep 2
|
||||
showMainMenu
|
||||
fi
|
||||
else
|
||||
showLog "The official UI does not exist."
|
||||
showLog "$MSG_ORIGINAL_UI_IS_MISSING"
|
||||
sleep 2
|
||||
showMainMenu
|
||||
fi
|
||||
|
@ -350,17 +466,26 @@ downloadInstallScript() {
|
|||
if [ -f "$SCRIPT_NAME" ]; then
|
||||
rm "$SCRIPT_NAME"
|
||||
fi
|
||||
showLog "Re-downloading the installation script..."
|
||||
showLog "$MSG_DOWNLOADING_INSTALL_SCRIPT"
|
||||
wget "https://github.com/ronggang/transmission-web-control/raw/master/release/$SCRIPT_NAME" --no-check-certificate
|
||||
# 判断是否下载成功
|
||||
if [ $? -eq 0 ]; then
|
||||
showLog "The download is complete. Please re-run the installation script."
|
||||
showLog "$MSG_INSTALL_SCRIPT_DOWNLOAD_COMPLETE"
|
||||
else
|
||||
showLog "Installation script failed to download!"
|
||||
showLog "$MSG_INSTALL_SCRIPT_DOWNLOAD_FAILED"
|
||||
sleep 2
|
||||
showMainMenu
|
||||
fi
|
||||
}
|
||||
|
||||
# 执行
|
||||
showMainMenu
|
||||
if [ "$USER" != 'root' ]; then
|
||||
showLog "$MSG_NON_ROOT_USER"
|
||||
exit -1
|
||||
fi
|
||||
|
||||
if [ $AUTOINSTALL = 1 ]; then
|
||||
main
|
||||
else
|
||||
# 执行
|
||||
showMainMenu
|
||||
fi
|
Loading…
Reference in New Issue
Block a user