Commit 02b8838b authored by Philip Müller's avatar Philip Müller
Browse files

[pkg-upd] 20210826-2

- provide USB Tethering scripts
- fixes #2
parent 26e42025
......@@ -4,7 +4,7 @@
pkgname=pinephone-manjaro-tweaks
pkgver=20$(date +%y%m%d)
pkgrel=1
pkgrel=2
pkgdesc="Manjaro ARM's PinePhone tweaks"
arch=('any')
url="https://www.manjaro.org"
......@@ -46,7 +46,11 @@ source=(manjaro-tweaks.sh
org.gtk.PrintEditor4.desktop
org.gtk.WidgetFactory4.desktop
packagekit-rm-lock.service
gsk-renderer-gl.sh)
gsk-renderer-gl.sh
pinephone-setup-usb-network.sh
pinephone-usb-gadget.sh
pinephone-setup-usb-network.service
pinephone-usb-gadget.service)
install=$pkgname.install
sha256sums=('9f0b66d985a52a337c0caf5a6aa93793ce148b50035e34d8171cdb9fc8527431'
'4c98246755eb037d8a934d585d01961952ff38633c3fc8a53f41fcc6d5dcde3f'
......@@ -83,7 +87,11 @@ sha256sums=('9f0b66d985a52a337c0caf5a6aa93793ce148b50035e34d8171cdb9fc8527431'
'10220f5347ad8faadf2b1bc203252bbbcfd11c26a78cd9ca4f4499dd05948e0c'
'287413cb7244af7ef6edb2c27fb46f2ed4528433424270c44c36be7c3c92d824'
'9972492d0f79cf1205d35f06034790f32ea1b5b1dd2c8f5bdf94938c2b4c2d82'
'f856109133c8707010f17367dbcde1c480b05f5faf5703fe62ca43786b029818')
'f856109133c8707010f17367dbcde1c480b05f5faf5703fe62ca43786b029818'
'aac27e7ef1ed269cd56208f0300504f6872036b946581146a45465ae38525023'
'5040bf053cc07ec164199fe10572e9df2b3ca3c45a539b83ffee0ef286bf9521'
'90434a7d5c6988e32bca345adb90268640c3bbb8db2c02e1c979abb8cdaa2525'
'7939a0deae1f78af0c17561dc69093929c3773aad7e72e94b8d8bbff2cf66049')
pkgver() {
printf 20$(date +%y%m%d)
......@@ -91,8 +99,8 @@ pkgver() {
package() {
# Hide apps we don't care
mkdir -p "$pkgdir"/usr/share/manjaro/applications
cp "$srcdir"/*.desktop "$pkgdir"/usr/share/manjaro/applications/
mkdir -p "${pkgdir}"/usr/share/manjaro/applications
cp "${srcdir}"/*.desktop "${pkgdir}"/usr/share/manjaro/applications/
# Install gtk3 settings
install -Dm644 "${srcdir}/gtk3-settings.ini" "${pkgdir}/etc/gtk-3.0/settings.ini"
......@@ -110,9 +118,14 @@ package() {
install -Dm644 "${srcdir}/90-pinephone.conf" -t "${pkgdir}/etc/pulse/daemon.conf.d"
install -Dm644 "${srcdir}/pinephone.pa" -t "${pkgdir}/etc/pulse"
install -Dm644 "${srcdir}/00-journal-size.conf" "${pkgdir}/etc/systemd/journald.conf.d/00-journal-size.conf"
install -Dm644 "$srcdir/packagekit-rm-lock.service" "$pkgdir/usr/lib/systemd/system/packagekit-rm-lock.service"
mkdir -p "$pkgdir/usr/lib/systemd/system/system-update.target.wants"
ln -s ../packagekit-rm-lock.service "$pkgdir/usr/lib/systemd/system/system-update.target.wants/packagekit-rm-lock.service"
install -Dm644 "${srcdir}/packagekit-rm-lock.service" "${pkgdir}/usr/lib/systemd/system/packagekit-rm-lock.service"
mkdir -p "${pkgdir}/usr/lib/systemd/system/system-update.target.wants"
ln -s ../packagekit-rm-lock.service "${pkgdir}/usr/lib/systemd/system/system-update.target.wants/packagekit-rm-lock.service"
# Prevent artifacts in GTK4 apps (pmaports#1069)
install -Dm755 "$srcdir"/gsk-renderer-gl.sh -t "$pkgdir"/etc/profile.d/
install -Dm755 "${srcdir}"/gsk-renderer-gl.sh -t "${pkgdir}"/etc/profile.d/
# Enable USB Tethering
install -Dm755 "${srcdir}"/pinephone-setup-usb-network.sh -t "${pkgdir}"/usr/bin
install -Dm755 "${srcdir}"/pinephone-usb-gadget.sh -t "${pkgdir}"/usr/bin
install -Dm644 "${srcdir}"/pinephone-setup-usb-network.service -t "${pkgdir}"/usr/lib/systemd/system
install -Dm644 "${srcdir}"/pinephone-usb-gadget.service "${pkgdir}"/usr/lib/systemd/system
}
[Unit]
Description=Setup USB networking
Requires=NetworkManager.service
After=NetworkManager.service
ConditionFirstBoot=yes
[Service]
Type=oneshot
ExecStart=/usr/bin/pinephone-setup-usb-network.sh
[Install]
WantedBy=multi-user.target
#!/bin/sh
if [ ! -e /etc/NetworkManager/system-connections/USB.nmconnection ]; then
# Create network connection
nmcli connection add con-name USB \
ifname usb0 \
type ethernet \
ip4 10.66.0.1/8
# Set priorities so it doesn't take precedence over WiFi/mobile connections
nmcli connection modify USB ipv4.route-metric 1500
nmcli connection modify USB ipv4.dns-priority 150
# Share connection so it can be used for tethering
nmcli connection modify USB ipv4.method shared
fi
[Unit]
Description=Configure USB gadget
Before=umtp-responder.service
[Service]
Type=oneshot
ExecStart=/usr/bin/pinephone-usb-gadget.sh setup
ExecStop=/usr/bin/pinephone-usb-gadget.sh reset
RemainAfterExit=yes
[Install]
WantedBy=default.target
#!/bin/sh
CONFIGFS=/sys/kernel/config/usb_gadget/g1
USB_VENDORID="0x1D6B" # Linux Foundation
USB_PRODUCTID="0x0104" # Multifunction composite gadget
USB_MANUF="Manjaro"
USB_PRODUCT="Manjaro"
USB_SERIAL=`cat /etc/machine-id`
setup() {
# Don't do anything if the USB gadget already exists
[ -d $CONFIGFS ] && exit 0
# Required to make a composite gadget
modprobe libcomposite
# Create all required directories
echo "Creating the USB gadget..."
mkdir -p $CONFIGFS
mkdir -p $CONFIGFS/strings/0x409
mkdir -p $CONFIGFS/configs/c.1
mkdir -p $CONFIGFS/configs/c.1/strings/0x409
# Setup IDs and strings
echo "Setting up gadget strings..."
echo $USB_VENDORID > $CONFIGFS/idVendor
echo $USB_PRODUCTID > $CONFIGFS/idProduct
echo $USB_MANUF > $CONFIGFS/strings/0x409/manufacturer
echo $USB_PRODUCT > $CONFIGFS/strings/0x409/product
echo $USB_SERIAL > $CONFIGFS/strings/0x409/serialnumber
# Create ECM (ethernet) function
echo "Adding ECM function..."
mkdir $CONFIGFS/functions/ecm.usb0
# Create configuration
echo "Creating gadget configuration..."
echo "Ethernet" > $CONFIGFS/configs/c.1/strings/0x409/configuration
ln -s $CONFIGFS/functions/ecm.usb0 $CONFIGFS/configs/c.1
}
start() {
echo "Enabling the USB gadget..."
sleep 1
UDC=`ls /sys/class/udc`
echo "$UDC" > $CONFIGFS/UDC
}
reset() {
echo "Removing the USB gadget..."
# Remove USB gadget
if [ -d $CONFIGFS ]; then
echo "Removing gadget configuration..."
rm $CONFIGFS/configs/c.1/ecm.usb0
rmdir $CONFIGFS/configs/c.1/strings/0x409/
rmdir $CONFIGFS/configs/c.1/
rmdir $CONFIGFS/functions/ecm.usb0
rmdir $CONFIGFS/strings/0x409/
rmdir $CONFIGFS
fi
}
case "$1" in
reset) reset ;;
setup) setup ;;
start) start ;;
*) ;;
esac
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment