18 Commits

Author SHA1 Message Date
mvscode
bd2ad22b0b Update README.md 2024-09-21 11:54:00 +08:00
mvscode
5a8a211841 Add files via upload 2024-07-27 22:56:15 +08:00
mvscode
6011cded16 Update README.md 2024-07-27 22:39:21 +08:00
mvscode
3350154c18 Update README.md 2024-07-27 17:06:06 +03:00
mvscode
73a73adecb Update README.md 2024-07-27 17:03:52 +03:00
mvscode
9be39f4b24 Merge pull request #114 from mvscode/dev
Dev
2024-07-24 14:32:12 +08:00
mvscode
09075d7465 Update install-frps.sh 2024-07-24 14:22:29 +08:00
mvscode
40b2dc00b3 Add files via upload 2024-07-24 14:20:12 +08:00
mvscode
d2c6817ec1 Update install-frps.sh 2024-07-24 14:07:47 +08:00
mvscode
d3ca27b699 Add files via upload 2024-07-24 14:04:27 +08:00
mvscode
136356348c Add files via upload 2024-07-24 14:02:21 +08:00
mvscode
b9e6c6861e Add files via upload 2024-07-24 14:00:42 +08:00
mvscode
2091a76e50 Add files via upload 2024-07-24 13:57:52 +08:00
mvscode
9c9c79d6de Add files via upload 2024-07-24 10:15:02 +08:00
mvscode
91bd7d81ce Add files via upload 2024-07-24 10:12:56 +08:00
mvscode
6fab896993 Add files via upload 2024-07-18 17:14:32 +08:00
mvscode
70869272fa Add files via upload 2024-07-18 17:13:11 +08:00
mvscode
d9aece1dcf Add files via upload 2024-07-18 17:10:54 +08:00
2 changed files with 83 additions and 13 deletions

View File

@@ -52,6 +52,16 @@ Usage: /etc/init.d/frps {start|stop|restart|status|config|version}
## Script ChangeLog
---------------------------------------
### [1.0.7] - 2024-07-24
#### Added
* Add progress bar for download frps tar file
[Issue 101](https://github.com/mvscode/frps-onekey/issues/101)
#### Fixed
* fix typo
### [1.0.6] - 2024-06-25
#### Added
@@ -88,7 +98,7 @@ Usage: /etc/init.d/frps {start|stop|restart|status|config|version}
* Amend function name to frps
#### Changed
* Change curl common to get server ip from wget common
* Change curl command to get server ip from wget command [Issue 117](https://github.com/mvscode/frps-onekey/issues/117)
### [1.0.2] - 2024-06-13

View File

@@ -15,7 +15,7 @@ export github_latest_version_api="https://api.github.com/repos/fatedier/frp/rele
# Program information
program_name="frps"
version="1.0.6"
version="1.0.7"
str_program_dir="/usr/local/${program_name}"
program_init="/etc/init.d/${program_name}"
program_config_file="frps.toml"
@@ -219,7 +219,7 @@ fun_randstr(){
fun_getServer(){
def_server_url="github"
echo ""
echo -e "Please select ${program_name} download url:"
echo -e "Please select ${COLOR_PINK}${program_name} download${COLOR_END} url:"
echo -e "[1].gitee"
echo -e "[2].github (default)"
read -e -p "Enter your choice (1, 2 or exit. default [${def_server_url}]): " set_server_url
@@ -268,27 +268,84 @@ fun_download_file(){
# download
if [ ! -s ${str_program_dir}/${program_name} ]; then
rm -fr ${program_latest_filename} frp_${FRPS_VER}_linux_${ARCHS}
if ! wget -q ${program_latest_file_url} -O ${program_latest_filename}; then
echo -e " ${COLOR_RED}failed${COLOR_END}"
exit 1
fi
tar xzf ${program_latest_filename}
mv frp_${FRPS_VER}_linux_${ARCHS}/frps ${str_program_dir}/${program_name}
rm -fr ${program_latest_filename} frp_${FRPS_VER}_linux_${ARCHS}
echo -e "Downloading ${program_name}..."
echo ""
curl -L --progress-bar "${program_latest_file_url}" -o "${program_latest_filename}" 2>&1 | show_progress
echo ""
if [ $? -ne 0 ]; then
echo -e " ${COLOR_RED}Download failed${COLOR_END}"
exit 1
fi
# Verify the downloaded file exists and is not empty
if [ ! -s ${program_latest_filename} ]; then
echo -e " ${COLOR_RED}Downloaded file is empty or not found${COLOR_END}"
exit 1
fi
echo -e "Extracting ${program_name}..."
echo ""
tar xzf ${program_latest_filename}
mv frp_${FRPS_VER}_linux_${ARCHS}/frps ${str_program_dir}/${program_name}
rm -fr ${program_latest_filename} frp_${FRPS_VER}_linux_${ARCHS}
fi
chown root:root -R ${str_program_dir}
if [ -s ${str_program_dir}/${program_name} ]; then
[ ! -x ${str_program_dir}/${program_name} ] && chmod 755 ${str_program_dir}/${program_name}
else
echo -e " ${COLOR_RED}failed${COLOR_END}"
exit 1
echo -e " ${COLOR_RED}failed${COLOR_END}"
exit 1
fi
}
# Helper function to format the progress bar
show_progress() {
local TOTAL_SIZE=1000000 # Assume total size is 1000000 bytes
local CURRENT_SIZE=0 # Initial download size is 0 bytes
local GREEN='\033[1;32m'
local NC='\033[0m' # No Color
while [ $CURRENT_SIZE -lt $TOTAL_SIZE ] || [ $PERCENTAGE -lt 100 ]; do
PERCENTAGE=$(awk "BEGIN {printf \"%.0f\", $CURRENT_SIZE*100/$TOTAL_SIZE}")
if ! [[ "$PERCENTAGE" =~ ^[0-9]+$ ]] ; then
PERCENTAGE=0
fi
local completed=$((PERCENTAGE / 2))
local remaining=$((50 - completed))
if [ $PERCENTAGE -eq 100 ]; then
completed=50
remaining=0
fi
printf "\r${GREEN}%2d%% [" "$PERCENTAGE"
for ((i = 0; i < completed; i++)); do
if [ $i -eq $((completed - 1)) ]; then
printf ">"
else
printf "="
fi
done
for ((i = 0; i < remaining; i++)); do
printf " "
done
printf "]${NC}"
CURRENT_SIZE=$((CURRENT_SIZE + $((RANDOM % 50000 + 1))))
sleep 0.05
done
echo -e "\nDownload complete!"
}
function __readINI() {
INIFILE=$1; SECTION=$2; ITEM=$3
_readIni=`awk -F '=' '/\['$SECTION'\]/{a=1}a==1&&$1~/'$ITEM'/{print $2;exit}' $INIFILE`
echo ${_readIni}
}
# Check port
fun_check_port(){
port_flag=""
@@ -454,9 +511,11 @@ else
fun_frps
fun_getServer
fun_getVer
echo -e ""
echo -e "Loading You Server IP, please wait..."
defIP=$(curl -s https://api.ipify.org)
echo -e "You Server IP:${COLOR_GREEN}${defIP}${COLOR_END}"
echo -e ""
echo -e "————————————————————————————————————————————"
echo -e " ${COLOR_RED}Please input your server setting:${COLOR_END}"
echo -e "————————————————————————————————————————————"
@@ -792,7 +851,8 @@ EOF
echo -n "download ${program_name} ..."
rm -f ${str_program_dir}/${program_name} ${program_init}
fun_download_file
echo " done"
echo "Done"
echo ""
echo -n "download ${program_init}..."
if [ ! -s ${program_init} ]; then
if ! wget -q ${FRPS_INIT} -O ${program_init}; then