-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from Anonym-tsk/ipk
opkg packages build system
- Loading branch information
Showing
11 changed files
with
325 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
name: Build and publish release | ||
|
||
on: | ||
push: | ||
branches: [ "master" ] | ||
pull_request: | ||
branches: [ "master" ] | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Bump version | ||
id: bump_version | ||
uses: remorses/bump-version@v8 | ||
with: | ||
version_file: ./VERSION | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Build packages | ||
run: make all | ||
|
||
- name: Create Release | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ github.ref }} | ||
release_name: Release ${{ github.ref }} | ||
draft: true | ||
prerelease: false | ||
|
||
- name: Upload Release mips | ||
id: upload-release-asset | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: ./out/nfqws-keenetic_${{ steps.bump_version.outputs.version }}_mips-3.4.ipk | ||
asset_name: nfqws-keenetic_${{ steps.bump_version.outputs.version }}_mips-3.4.ipk | ||
asset_content_type: application/octet-stream | ||
|
||
- name: Upload Release mipsel | ||
id: upload-release-asset | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: ./out/nfqws-keenetic_${{ steps.bump_version.outputs.version }}_mipsel-3.4.ipk | ||
asset_name: nfqws-keenetic_${{ steps.bump_version.outputs.version }}_mipsel-3.4.ipk | ||
asset_content_type: application/octet-stream | ||
|
||
- name: Upload Release aarch64 | ||
id: upload-release-asset | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: ./out/nfqws-keenetic_${{ steps.bump_version.outputs.version }}_aarch64-3.10.ipk | ||
asset_name: nfqws-keenetic_${{ steps.bump_version.outputs.version }}_aarch64-3.10.ipk | ||
asset_content_type: application/octet-stream | ||
|
||
- name: Upload Release armv7 | ||
id: upload-release-asset | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: ./out/nfqws-keenetic_${{ steps.bump_version.outputs.version }}_armv7-3.2.ipk | ||
asset_name: nfqws-keenetic_${{ steps.bump_version.outputs.version }}_armv7-3.2.ipk | ||
asset_content_type: application/octet-stream |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
VERSION := $(shell cat VERSION) | ||
|
||
.DEFAULT_GOAL := all | ||
|
||
_clean: | ||
rm -rf out/$(ARCH) | ||
mkdir -p out/$(ARCH)/control | ||
mkdir -p out/$(ARCH)/data | ||
|
||
_conffiles: | ||
echo "/opt/etc/nfqws/nfqws.conf" > out/$(ARCH)/control/conffiles | ||
echo "/opt/etc/nfqws/user.list" >> out/$(ARCH)/control/conffiles | ||
echo "/opt/etc/nfqws/auto.list" >> out/$(ARCH)/control/conffiles | ||
echo "/opt/etc/nfqws/exclude.list" >> out/$(ARCH)/control/conffiles | ||
|
||
_control: | ||
echo "Package: nfqws-keenetic" > out/$(ARCH)/control/control | ||
echo "Version: $(VERSION)" >> out/$(ARCH)/control/control | ||
echo "Depends: busybox, iptables" >> out/$(ARCH)/control/control | ||
echo "License: MIT" >> out/$(ARCH)/control/control | ||
echo "Section: net" >> out/$(ARCH)/control/control | ||
echo "URL: https://github.com/Anonym-tsk/nfqws-keenetic" >> out/$(ARCH)/control/control | ||
echo "Architecture: $(ARCH)-$(KERNEL)" >> out/$(ARCH)/control/control | ||
echo "Description: NFQWS service" >> out/$(ARCH)/control/control | ||
|
||
_scripts: | ||
cp common/ipk/preinst out/$(ARCH)/control/preinst | ||
cp common/ipk/postinst out/$(ARCH)/control/postinst | ||
cp common/ipk/prerm out/$(ARCH)/control/prerm | ||
cp common/ipk/postrm out/$(ARCH)/control/postrm | ||
|
||
_debian-binary: | ||
echo 2.0 > out/$(ARCH)/debian-binary | ||
|
||
_binary: | ||
mkdir -p out/$(ARCH)/data/opt/usr/bin | ||
curl -sSL $(URL) -o out/$(ARCH)/data/opt/usr/bin/nfqws | ||
chmod +x out/$(ARCH)/data/opt/usr/bin/nfqws | ||
|
||
_version: | ||
sed -i "s#VERSION=\"0.0.0\"#VERSION=\"$(VERSION)\"#" out/$(ARCH)/data/opt/etc/init.d/S51nfqws | ||
|
||
_ipk: | ||
# cleanup | ||
make _clean | ||
|
||
# control.tar.gz | ||
make _conffiles | ||
make _control | ||
make _scripts | ||
cd out/$(ARCH)/control; tar czvf ../control.tar.gz .; cd ../../.. | ||
|
||
# data.tar.gz | ||
make _binary | ||
cp -r etc out/$(ARCH)/data/opt/etc | ||
make _version | ||
cd out/$(ARCH)/data; tar czvf ../data.tar.gz .; cd ../../.. | ||
|
||
# ipk | ||
make _debian-binary | ||
#ar -r out/nfqws-keenetic_$(VERSION)_$(ARCH)-3.10.ipk out/$(ARCH)/control.tar.gz out/$(ARCH)/data.tar.gz out/$(ARCH)/debian-binary | ||
cd out/$(ARCH); tar czvf ../nfqws-keenetic_$(VERSION)_$(ARCH)-$(KERNEL).ipk control.tar.gz data.tar.gz debian-binary; cd ../.. | ||
|
||
mipsel: | ||
make ARCH=mipsel KERNEL=3.4 URL="https://raw.githubusercontent.com/bol-van/zapret/master/binaries/mips32r1-lsb/nfqws" _ipk | ||
|
||
mips: | ||
make ARCH=mips KERNEL=3.4 URL="https://raw.githubusercontent.com/bol-van/zapret/master/binaries/mips32r1-msb/nfqws" _ipk | ||
|
||
aarch64: | ||
make ARCH=aarch64 KERNEL=3.10 URL="https://raw.githubusercontent.com/bol-van/zapret/master/binaries/aarch64/nfqws" _ipk | ||
|
||
armv7: | ||
make ARCH=armv7 KERNEL=3.2 URL="https://raw.githubusercontent.com/bol-van/zapret/master/binaries/arm/nfqws" _ipk | ||
|
||
all: mipsel mips aarch64 armv7 | ||
|
||
clean: | ||
rm -rf out/mipsel | ||
rm -rf out/mips | ||
rm -rf out/aarch64 | ||
rm -rf out/armv7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
2.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
#!/bin/sh | ||
|
||
CONFDIR=/opt/etc/nfqws | ||
CONFFILE=$CONFDIR/nfqws.conf | ||
LISTFILE=$CONFDIR/user.list | ||
LISTAUTOFILE=$CONFDIR/auto.list | ||
LISTEXCLUDEFILE=$CONFDIR/exclude.list | ||
LISTLOG=/opt/var/log/nfqws.log | ||
INIT_SCRIPT=/opt/etc/init.d/S51nfqws | ||
|
||
stop_func() { | ||
if [ -f "$INIT_SCRIPT" ]; then | ||
$INIT_SCRIPT stop | ||
fi | ||
} | ||
|
||
start_func() { | ||
if [ -f "$INIT_SCRIPT" ]; then | ||
$INIT_SCRIPT start | ||
fi | ||
} | ||
|
||
show_interfaces_func() { | ||
echo -e "\n----------------------" | ||
ip addr show | awk -F" |/" '{gsub(/^ +/,"")}/inet /{print $(NF), $2}' | ||
} | ||
|
||
config_interface_func() { | ||
if [ -z "$BIND_IFACE" ]; then | ||
echo -e "\nEnter the provider interface name from the list above, e.g. eth3 (default) or nwg1" | ||
echo "You can specify multiple interfaces separated by space, e.g. eth3 nwg1" | ||
read BIND_IFACE | ||
fi | ||
if [ -z "$BIND_IFACE" ]; then | ||
BIND_IFACE="eth3" | ||
fi | ||
echo "Selected interface: $BIND_IFACE" | ||
|
||
sed -i "s#INPUT_ISP_INTERFACE#$BIND_IFACE#" $CONFFILE | ||
} | ||
|
||
config_select_mode_func() { | ||
if [ -z "$MODE" ]; then | ||
echo -e "\nSelect working mode: auto (default), list, all" | ||
echo " auto - automatically detects blocked resources and adds them to the list" | ||
echo " list - applies rules only to domains in the list $LISTFILE" | ||
echo " all - applies rules to all traffic except domains from list $LISTEXCLUDEFILE" | ||
read MODE | ||
fi | ||
|
||
if [ "$MODE" == "list" ]; then | ||
EXTRA_ARGS="--hostlist=$LISTFILE" | ||
elif [ "$MODE" == "all" ]; then | ||
EXTRA_ARGS="--hostlist-exclude=$LISTEXCLUDEFILE" | ||
else | ||
MODE="auto" | ||
EXTRA_ARGS="--hostlist=$LISTFILE --hostlist-auto=$LISTAUTOFILE --hostlist-auto-debug=$LISTLOG --hostlist-exclude=$LISTEXCLUDEFILE" | ||
fi | ||
echo "Selected mode: $MODE" | ||
|
||
sed -i "s#INPUT_EXTRA_ARGS#$EXTRA_ARGS#" $CONFFILE | ||
} | ||
|
||
config_ipv6_func() { | ||
echo -e "\nDisable IPv6 support (enabled by default)? y/N" | ||
read yn | ||
case $yn in | ||
[Yy]* ) | ||
sed -i "s#IPV6_ENABLED=1#IPV6_ENABLED=0#" $CONFFILE | ||
;; | ||
esac | ||
} | ||
|
||
# Stop service if exist | ||
stop_func | ||
|
||
NFQWS_INSTALL_TYPE="install" | ||
if [ -f "/tmp/nfqws_install_type" ]; then | ||
# Set in preinst script | ||
NFQWS_INSTALL_TYPE=$(cat "/tmp/nfqws_install_type") | ||
rm -f /tmp/nfqws_install_type | ||
fi | ||
|
||
case "$NFQWS_INSTALL_TYPE" in | ||
install) | ||
# Setup ISP interface | ||
show_interfaces_func | ||
config_interface_func | ||
|
||
# Setup working mode | ||
config_select_mode_func | ||
|
||
# Setup IPv6 support | ||
config_ipv6_func | ||
|
||
echo "Installation successful" | ||
;; | ||
*) | ||
# Do nothing | ||
;; | ||
esac | ||
|
||
# Starting Services | ||
start_func | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/sh | ||
|
||
CONFDIR=/opt/etc/nfqws | ||
LISTLOG=/opt/var/log/nfqws.log | ||
|
||
remove_all_files_func() { | ||
rm -f $LISTLOG | ||
echo -e "\nRemove lists and config? y/N" | ||
read yn | ||
case $yn in | ||
[Yy]* ) | ||
rm -rf $CONFDIR | ||
;; | ||
esac | ||
} | ||
|
||
case "$1" in | ||
upgrade) | ||
# Do nothing | ||
;; | ||
*) | ||
# Remove all data | ||
remove_all_files_func | ||
|
||
echo "Unnstallation successful" | ||
;; | ||
esac | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/sh | ||
|
||
# Set `install` or `upgrade` for postinst script | ||
echo "$1" > /tmp/nfqws_install_type | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/sh | ||
|
||
INIT_SCRIPT=/opt/etc/init.d/S51nfqws | ||
|
||
stop_func() { | ||
if [ -f "$INIT_SCRIPT" ]; then | ||
$INIT_SCRIPT stop | ||
fi | ||
} | ||
|
||
# Stop service if exist | ||
stop_func | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters