oyo init
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,8 +1,5 @@
|
||||
|
||||
|
||||
# Other files and folders
|
||||
.settings/
|
||||
|
||||
# Executables
|
||||
*.swf
|
||||
*.air
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
Package: oyo
|
||||
Version: 1.0
|
||||
Maintainer: shenmo <shenmo@spark-app.store>
|
||||
Priority: optional
|
||||
Section: utils
|
||||
Installed-Size:10
|
||||
Depends: curl
|
||||
Depends: curl,transhell
|
||||
Description: Aptss for Yoyo OS
|
||||
Architecture: all
|
||||
Homepage: https://gitee.com/spark-community-works-collections/oyo
|
||||
|
||||
0
OYO/opt/durapps/oyo/yoyo-getfastmirror/.keep
Normal file
0
OYO/opt/durapps/oyo/yoyo-getfastmirror/.keep
Normal file
@@ -1,140 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
VERSION="kokomi"
|
||||
|
||||
TEST_NETCONNECT_HOST="www.baidu.com"
|
||||
|
||||
SOURCES_MIRRORS_FILE="/etc/yoyo-apt/sources_mirrors.list"
|
||||
|
||||
MIRRORS_SPEED_FILE="/etc/yoyo-apt/mirrors_speed.list"
|
||||
|
||||
SOURCES_MIRRORS_FILE_URL="https://packages.yzzi.icu/sources_mirrors.list"
|
||||
|
||||
function get_mirror_list()
|
||||
{
|
||||
wget $SOURCES_MIRRORS_FILE_URL --output-document=$SOURCES_MIRRORS_FILE
|
||||
}
|
||||
|
||||
function get_ping_speed() #return average ping $1 time
|
||||
|
||||
{
|
||||
|
||||
local speed=`ping -W1 -c1 $1 2> /dev/null | grep "^rtt" | cut -d '/' -f5`
|
||||
|
||||
echo $speed
|
||||
|
||||
}
|
||||
|
||||
function test_mirror_speed() #
|
||||
|
||||
{
|
||||
|
||||
rm $MIRRORS_SPEED_FILE 2> /dev/null; touch $MIRRORS_SPEED_FILE
|
||||
|
||||
|
||||
|
||||
cat $SOURCES_MIRRORS_FILE | while read mirror
|
||||
|
||||
do
|
||||
|
||||
if [ "$mirror" != "" ]; then
|
||||
|
||||
echo -e "Ping $mirror c"
|
||||
|
||||
local mirror_host=`echo $mirror | cut -d '/' -f3` #change mirror_url to host
|
||||
|
||||
|
||||
|
||||
local speed=$(get_ping_speed $mirror_host)
|
||||
|
||||
|
||||
|
||||
if [ "$speed" != "" ]; then
|
||||
|
||||
echo "Time is $speed"
|
||||
|
||||
echo "$mirror $speed" >> $MIRRORS_SPEED_FILE
|
||||
|
||||
else
|
||||
|
||||
echo "Connected failed."
|
||||
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
}
|
||||
|
||||
function get_fast_mirror()
|
||||
|
||||
{
|
||||
|
||||
sort -k 2 -n -o $MIRRORS_SPEED_FILE $MIRRORS_SPEED_FILE
|
||||
|
||||
local fast_mirror=`head -n 1 $MIRRORS_SPEED_FILE | cut -d ' ' -f1`
|
||||
|
||||
echo $fast_mirror
|
||||
|
||||
}
|
||||
|
||||
function update_sources()
|
||||
|
||||
{
|
||||
|
||||
local COMP="main"
|
||||
|
||||
local mirror="$1"
|
||||
|
||||
local tmp=$(mktemp)
|
||||
|
||||
echo "deb $mirror $VERSION $COMP" >> $tmp
|
||||
|
||||
sudo mv "$tmp" /etc/apt/sources.list.d/yoyo-os.list
|
||||
|
||||
echo -e "Your sources has been updated.n";
|
||||
|
||||
}
|
||||
|
||||
echo -e "nTesting the network connection.nPlease wait... c"
|
||||
|
||||
if [ "$(get_ping_speed $TEST_NETCONNECT_HOST)" == "" ]; then
|
||||
|
||||
echo -e "Network is bad.nPlease check your network."; exit 1
|
||||
|
||||
else
|
||||
|
||||
echo -e "Network is good.n"
|
||||
|
||||
mkdir -p /etc/yoyo-apt/
|
||||
|
||||
get_mirror_list
|
||||
|
||||
test -f $SOURCES_MIRRORS_FILE
|
||||
|
||||
if [ "$?" != "0" ]; then
|
||||
|
||||
echo -e "$SOURCES_MIRRORS_FILE is not exist.n"; exit 2
|
||||
|
||||
else
|
||||
|
||||
test_mirror_speed
|
||||
|
||||
fast_mirror=$(get_fast_mirror)
|
||||
|
||||
if [ "$fast_mirror" == "" ]; then
|
||||
|
||||
echo -e "Can't find the fastest software sources. Please check your $SOURCES_MIRRORS_FILEn"
|
||||
|
||||
exit 0
|
||||
|
||||
fi
|
||||
|
||||
update_sources $fast_mirror
|
||||
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
exit 0
|
||||
6
OYO/usr/bin/apt
Executable file
6
OYO/usr/bin/apt
Executable file
@@ -0,0 +1,6 @@
|
||||
#!/bin/bash
|
||||
source /opt/durapps/transhell/transhell.sh
|
||||
load_transhell
|
||||
|
||||
echo "${TRANSHELL_CONTENT_APT_IS_PROVIDED_BY_OYO} "
|
||||
oyo $@
|
||||
28
OYO/usr/bin/oyo
Normal file
28
OYO/usr/bin/oyo
Normal file
@@ -0,0 +1,28 @@
|
||||
#!/bin/bash
|
||||
|
||||
source /opt/durapps/transhell/transhell.sh
|
||||
load_transhell
|
||||
|
||||
YY_APT_FAST=/opt/durapps/oyo/apt-fast/yy-apt-fast
|
||||
YOYO_GETFASTMIRROR=/opt/durapps/oyo/yoyo-getfastmirror/yoyo-getfastmirror
|
||||
#####没有conf还不是root的就先root下获取conf
|
||||
if [ ! -e /tmp/oyo/apt-fast.conf] && [ "$(id -u)" != "0" ];then
|
||||
echo -e "${TRANSHELL_CONTENT_APT_FAST_CONF_NOT_FOUND_NEED_AUTH_TO_UPDATE}"
|
||||
pkexec $0 $@
|
||||
exit
|
||||
fi
|
||||
|
||||
##### 没有conf的获取conf再进行操作
|
||||
if [ ! -e /tmp/oyo/apt-fast.conf];then
|
||||
${YOYO_GETFASTMIRROR}
|
||||
apt-get update
|
||||
|
||||
fi
|
||||
##### yyupdate手动操作更新
|
||||
if [ "$1" = "yyupdate" ];then
|
||||
${YOYO_GETFASTMIRROR}
|
||||
apt-get update
|
||||
##### 其他的直接转给apt-fast
|
||||
else
|
||||
${YY_APT_FAST} $@
|
||||
fi
|
||||
3
OYO/usr/share/apt/transhell/apt_en_US.transhell
Normal file
3
OYO/usr/share/apt/transhell/apt_en_US.transhell
Normal file
@@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
TRANSHELL_CONTENT_APT_IS_PROVIDED_BY_OYO="Please do not use apt in shell, for in Yoyo OS, apt is provided by oyo."
|
||||
|
||||
3
OYO/usr/share/apt/transhell/apt_zh_CN.transhell
Normal file
3
OYO/usr/share/apt/transhell/apt_zh_CN.transhell
Normal file
@@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
TRANSHELL_CONTENT_APT_IS_PROVIDED_BY_OYO="请不要在脚本中使用apt,在Yoyo OS中,apt是由oyo提供的"
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
#!/bin/bash
|
||||
TRANSHELL_CONTENT_FAILED_TO_GET_MIRROR_INFO="E:Failed to get mirror info. Now exit. "
|
||||
|
||||
TRANSHELL_CONTENT_APT_FAST_CONF_NOT_FOUND_NEED_AUTH_TO_UPDATE="apt-fast.conf can not be found.\nThat might be because it's your first time running oyo after boot up\nWill try to authenticify to run yoyo-getfastmirror"
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
#!/bin/bash
|
||||
TRANSHELL_CONTENT_FAILED_TO_GET_MIRROR_INFO="错误:无法获取镜像信息,退出。"
|
||||
|
||||
TRANSHELL_CONTENT_APT_FAST_CONF_NOT_FOUND_NEED_AUTH_TO_UPDATE="无法找到apt-fast.conf\n这可能是因为这是你开机后第一次使用oyo\n尝试验证来运行 yoyo-getfastmirror"
|
||||
|
||||
Reference in New Issue
Block a user