Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
happy888888 committed Dec 19, 2020
1 parent abc87e8 commit 839d8d2
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 29 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ jobs:
GITHUB_TOKEN: ${{ secrets.MY_GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./ipk/WeiboTask_${{ github.event.inputs.version }}_mips_24kc.ipk
asset_name: WeiboTask_${{ github.event.inputs.version }}_mips_24kc.ipk
asset_path: ./ipk/WeiboTask_${{ github.event.inputs.version }}_mips.ipk
asset_name: WeiboTask_${{ github.event.inputs.version }}_mips.ipk
asset_content_type: application/x-gzip

- name: Upload linux_mipsle ipk
Expand All @@ -114,6 +114,6 @@ jobs:
GITHUB_TOKEN: ${{ secrets.MY_GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./ipk/WeiboTask_${{ github.event.inputs.version }}_mipsle_24kc.ipk
asset_name: WeiboTask_${{ github.event.inputs.version }}_mipsle_24kc.ipk
asset_path: ./ipk/WeiboTask_${{ github.event.inputs.version }}_mipsle.ipk
asset_name: WeiboTask_${{ github.event.inputs.version }}_mipsle.ipk
asset_content_type: application/x-gzip
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ WeiboTask
### 🚀使用方式

本项目***不会使用任何账号密码***,仅需要[新浪网](https://www.sina.com.cn/) 的一个名为`ALC`的cookie(获取方式见下面说明)并存放到config.json文件中 <br>
config.json文件会缓存您的cookie以***保存***和刷新您的登录状态,使登录状态一直有效而***不必重复登录***,从而方便放在路由器等设备上持续运行 <br>
config.json文件会缓存您的cookie以***保存***和刷新您的***登录状态***,使登录状态一直有效而***不必重复登录***,从而方便放在路由器等设备上持续运行 <br>

#### 一、Windows本地运行

Expand Down Expand Up @@ -43,16 +43,16 @@ config.json文件会缓存您的cookie以***保存***和刷新您的登录状态

* 2.2 安装
使用`xshell`等工具登录路由器,执行下面的命令安装 <br>
`wget -O /tmp/WeiboTask.ipk "https://github.com/happy888888/WeiboTask/releases/download/1.0.0/WeiboTask_1.0.0_`uname -m`_24kc.ipk" && opkg install /tmp/WeiboTask.ipk` <br>
使用`xftp`(`WinScp`)等软件修改路由器目录`/etc/WeiboTask/config.json`文件,把***步骤1.1***中获得的cookie值填写到`"name": "ALC"`下面的`"value": ""`字段,内容参照上面***步骤1.3***中所示图片 <br>
执行命令启动 <br>
`WeiboTask -c /etc/WeiboTask/config.json`
* 3.3 设置定时启动
使用`xshell`等工具登录路由器,执行下面的命令配置crontab <br>
`0 0 * * * /usr/bin/WeiboTask -c /etc/WeiboTask/config.json >>/etc/crontabs/root && /etc/init.d/cron reload` <br>
然后每天凌晨0点会自动运行 <br>
`当然路由器网页中有类似"定时任务"的功能可以把"0 0 * * * /usr/bin/WeiboTask -c /etc/WeiboTask/config.json"追加到后面一行保存,也有相同的效果`
```wget -O /tmp/WeiboTask.ipk "https://github.com/happy888888/WeiboTask/releases/download/1.0.0/WeiboTask_1.0.0_`uname -m`.ipk" && opkg install /tmp/WeiboTask.ipk``` <br>
在安装时会提示填入***步骤2.1***获取的cookie(ALC),然后程序会自动运行,默认在每天`00:00`自动签到

* 2.3 其他
启动程序的命令为`/etc/init.d/wbt start`
关闭程序的命令为`/etc/init.d/wbt stop`
重启程序的命令为`/etc/init.d/wbt restart`
安装完成如果输入了cookie(ALC)程序会自动启动不需要使用命令再启动一次
配置文件存放在`/etc/WeiboTask/config.json`文件中,包括保存的cookie和server酱推送的SCKEY以及每天的签到时间
卸载程序直接运行命令`opkg remove WeiboTask`

#### 三、github Actions运行

Expand Down
84 changes: 70 additions & 14 deletions publish_release/publish_ipk.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh
name="WeiboTask"

mkdir -p ./ipk/usr/bin
mkdir -p ./ipk/opt/bin

cat>./ipk/postinst<<EOF1
#!/bin/sh
Expand All @@ -11,46 +11,102 @@ if [ ! -f "/etc/WeiboTask/config.json" ]; then
`cat config.json`
EOF
fi
[ ! -d "/etc/init.d" ] && mkdir /etc/init.d
cat>/etc/init.d/wbt<<EOF
#!/bin/sh
START=50
start() {
echo "begin start"
pid=\\\`ps | grep WeiboTask | grep -v 'grep' | awk '{print \\\$1}' | head -n 1\\\`
if [ -n "\\\$pid" ]; then
echo "Already started!"
else
/opt/bin/WeiboTask -D
fi
}
stop() {
echo "begin stop"
pid=\\\`ps | grep WeiboTask | grep -v 'grep' | awk '{print \\\$1}' | head -n 1\\\`
if [ -n "\\\$pid" ]; then
kill -9 \\\$pid
echo "stopped"
else
echo "Error! not started!" 1>&2
fi
}
case "\\\$1" in
start)
start
exit 0
;;
stop)
stop
exit 0
;;
reload|restart|force-reload)
stop
start
exit 0
;;
**)
echo "Usage: \\\$0 {start|stop|reload}" 1>&2
exit 1
;;
esac
EOF
chmod 755 /etc/init.d/wbt
echo "安装成功,请在下方粘贴cookie(ALC)并回车,然后程序会立即启动"
echo "若直接回车,程序不会启动,请在/etc/WeiboTask/config.json中配置ALC后"
echo "使用命令/etc/init.d/wbt restart启动"
read -p "粘贴cookie(ALC):" ALC
if [ -n "\$ALC" ]; then
nn=\`grep -n '"name": "ALC"' /etc/WeiboTask/config.json | head -1 | cut -d ':' -f 1\`
let nn+=1
sed -i "\${nn}c \"value\": \"\${ALC}\"," /etc/WeiboTask/config.json
/opt/bin/WeiboTask -D
fi
EOF1

cat>./ipk/prerm<<EOF1
#!/bin/sh
[ -d "/etc/WeiboTask" ] && rm -rf /etc/WeiboTask
EOF
fi
[ -e "/etc/init.d/wbt" ] && rm -rf /etc/init.d/wbt
EOF1

chmod 755 ./ipk/postinst
chmod 755 ./ipk/prerm

echo "2.0" >./ipk/debian-binary


/bin/cp -f ./bin/linux_mips/$name ./ipk/usr/bin/
/bin/cp -f ./bin/linux_mips/$name ./ipk/opt/bin/

echo "Package: ${name}" >./ipk/control
echo "Version: ${version}" >>./ipk/control
echo "Section: lang" >>./ipk/control
echo "Maintainer: 星辰 <[email protected]>" >>./ipk/control
echo "Architecture: mips_24kc" >>./ipk/control
echo "Installed-Size: `stat -c "%s" ./ipk/usr/bin/$name`" >>./ipk/control
echo "Architecture: all" >>./ipk/control
echo "Installed-Size: `stat -c "%s" ./ipk/opt/bin/$name`" >>./ipk/control
echo "Description: 微博签到任务" >>./ipk/control

tar -zcvf ./ipk/data.tar.gz --transform s=/ipk== ./ipk/usr
tar -zcvf ./ipk/data.tar.gz --transform s=/ipk== ./ipk/opt
tar -zcvf ./ipk/control.tar.gz --transform s=/ipk== ./ipk/control ./ipk/postinst ./ipk/prerm
tar -zcvf ./ipk/${name}_${version}_mips_24kc.ipk --transform s=/ipk== ./ipk/data.tar.gz ./ipk/control.tar.gz ./ipk/debian-binary
tar -zcvf ./ipk/${name}_${version}_mips.ipk --transform s=/ipk== ./ipk/data.tar.gz ./ipk/control.tar.gz ./ipk/debian-binary


rm -f ./ipk/data.tar.gz ./ipk/control.tar.gz
/bin/cp -f ./bin/linux_mipsle/$name ./ipk/usr/bin/
/bin/cp -f ./bin/linux_mipsle/$name ./ipk/opt/bin/

echo "Package: ${name}" >./ipk/control
echo "Version: ${version}" >>./ipk/control
echo "Section: lang" >>./ipk/control
echo "Maintainer: 星辰 <[email protected]>" >>./ipk/control
echo "Architecture: mipsle_24kc" >>./ipk/control
echo "Installed-Size: `stat -c "%s" ./ipk/usr/bin/$name`" >>./ipk/control
echo "Architecture: all" >>./ipk/control
echo "Installed-Size: `stat -c "%s" ./ipk/opt/bin/$name`" >>./ipk/control
echo "Description: 微博签到任务" >>./ipk/control

tar -zcvf ./ipk/data.tar.gz --transform s=/ipk== ./ipk/usr
tar -zcvf ./ipk/data.tar.gz --transform s=/ipk== ./ipk/opt
tar -zcvf ./ipk/control.tar.gz --transform s=/ipk== ./ipk/control ./ipk/postinst ./ipk/prerm
tar -zcvf ./ipk/${name}_${version}_mipsle_24kc.ipk --transform s=/ipk== ./ipk/data.tar.gz ./ipk/control.tar.gz ./ipk/debian-binary
tar -zcvf ./ipk/${name}_${version}_mipsle.ipk --transform s=/ipk== ./ipk/data.tar.gz ./ipk/control.tar.gz ./ipk/debian-binary

rm -rf ./ipk/data.tar.gz ./ipk/control.tar.gz ./ipk/control ./ipk/postinst ./ipk/prerm ./ipk/usr ./ipk/debian-binary
rm -rf ./ipk/data.tar.gz ./ipk/control.tar.gz ./ipk/control ./ipk/postinst ./ipk/prerm ./ipk/opt ./ipk/debian-binary

0 comments on commit 839d8d2

Please sign in to comment.