aliyun coreos update 阿里云升级coreos

219 views
Skip to first unread message

Krast Blue

unread,
Mar 23, 2016, 2:19:55 AM3/23/16
to CoreOS Dev
阿里云升级难点在GFW。。。

思路:
自建代理  lantern 容器
自建升级服务器  nginx容器



阿里云默认CoreOS版本为681.2.0


查看CoreOS版本
iZ112hg7i1tZ / # cat /etc/os-release
NAME=CoreOS
ID=coreos
VERSION=681.2.0
VERSION_ID=681.2.0
BUILD_ID=
PRETTY_NAME="CoreOS 681.2.0"
ANSI_COLOR="1;32"

更改网络权限
iZ112hg7i1tZ / # chmod 777 -R /etc/systemd/network/*
iZ112hg7i1tZ / # ls -lha /etc/systemd/network/*
-rwxrwxrwx 1 root root 247 Mar 22 09:13 /etc/systemd/network/10-eth0.network
-rwxrwxrwx 1 root root 139 Mar 22 09:13 /etc/systemd/network/10-eth1.network

查看更新服务器
cat /etc/coreos/update.conf
GROUP=stable

查看当前使用的usr分区
iZ112hg7i1tZ / # df -h
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        2.0G     0  2.0G   0% /dev
tmpfs           2.0G     0  2.0G   0% /dev/shm
tmpfs           2.0G  424K  2.0G   1% /run
tmpfs           2.0G     0  2.0G   0% /sys/fs/cgroup
/dev/vda9        95G  3.0G   88G   4% /
/dev/vda3       985M  349M  585M  38% /usr
tmpfs           2.0G     0  2.0G   0% /media
tmpfs           2.0G     0  2.0G   0% /tmp
/dev/vda6       108M   56K   99M   1% /usr/share/oem



index.xml生成脚本

#!/bin/bash
cd /home/coreos_updates/
VERSION="$1" 

if [ ! -d $VERSION ]; then
        mkdir -p $VERSION
fi

if [ ! -f $VERSION/update.gz ]; then
        wget -qP $VERSION ${BASEURL}/amd64-usr/$VERSION/update.gz
fi

SIZE=$(stat -c %s ${VERSION}/update.gz)
SHA1_b64=$(echo -ne "$(echo -n $(sha1sum ${VERSION}/update.gz | awk '{print $1}') | sed -e 's/../\\x&/g')" | base64 )
SHA256_b64=$(echo -ne "$(echo -n $(sha256sum ${VERSION}/update.gz | awk '{print $1}') | sed -e 's/../\\x&/g')" | base64)

XML="<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<response protocol=\"3.0\" server=\"update.core-os.net\">
 <daystart elapsed_seconds=\"0\"></daystart>
 <app appid=\"e96281a6-d1af-4bde-9a0a-97b76e56dc57\" status=\"ok\">
  <updatecheck status=\"ok\">
   <urls>
    <url codebase=\"${URL}/${VERSION}/\"></url>
   </urls>
   <manifest version=\"${VERSION}\">
    <packages>
     <package hash=\"${SHA1_b64}\" name=\"update.gz\" size=\"${SIZE}\" required=\"false\"></package>
    </packages>
    <actions>
     <action event=\"postinstall\" ChromeOSVersion=\"\" sha256=\"${SHA256_b64}\" needsadmin=\"false\" IsDelta=\"false\" DisablePayloadBackoff=\"true\"></action>
    </actions>
   </manifest>
  </updatecheck>
 </app>
</response>" 

echo "$XML" > $VERSION/index.html

nginx docker

获取nginx docker镜像
docker pull nginx

生成nginx配置文件
cat > /home/default.conf << EOF
server {
        error_page 405 =200 $uri;
        location / {
            root /home/coreos_updates/amd64-usr;
            autoindex on;
            autoindex_exact_size off;
            autoindex_localtime on;
            allow all;
        }

        location /amd64-usr {
            root /home/coreos_updates;
            autoindex on;
            autoindex_exact_size off;
            autoindex_localtime on;
            allow all;
    }
}
EOF

启动nginx docker容器
docker run --name nginx -p 80:80 -v /home/coreos_updates/amd64-usr:/home/coreos_updates/amd64-usr:ro -v /home/default.conf:/etc/nginx/conf.d/default.conf:ro -d nginx

update-engine前台更新

update_engine_client -update


good luck!


Reply all
Reply to author
Forward
0 new messages