summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: b24ec110fb7997b0fa9dcc1f6d54ad8b330e4d7c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# Maintainer: KirTrub
pkgname=pyhotspot-git
pkgver=1.0.0
pkgrel=1
pkgdesc="Modern GUI for Linux Hotspot management (PyQt6 + NetworkManager)"
arch=('any')
url="https://github.com/KirTrub/PyWiHotspot"
license=('MIT')
depends=('python' 'python-pyqt6' 'python-qrcode' 'python-pillow' 'networkmanager' 'sh')
makedepends=('git')
provides=('pyhotspot')
conflicts=('pyhotspot')
source=('git+https://github.com/KirTrub/PyWiHotspot.git')
sha256sums=('SKIP')

package() {
  cd "$srcdir/PyWiHotspot"
  
  install -d "$pkgdir/usr/share/pyhotspot"
  install -d "$pkgdir/usr/bin"
  
  cp -r core ui widgets "$pkgdir/usr/share/pyhotspot/"
  
  echo -e "#!/bin/sh\npython /usr/share/pyhotspot/core/main.py \"\$@\"" > "$pkgdir/usr/bin/pyhotspot"
  chmod +x "$pkgdir/usr/bin/pyhotspot"

  echo "[Desktop Entry]
Name=PyWiHotspot
Exec=pyhotspot
Icon=network-wireless
Terminal=false
Type=Application
Categories=Network;System;" > pyhotspot.desktop
  
  install -Dm644 pyhotspot.desktop "$pkgdir/usr/share/applications/pyhotspot.desktop"


    install -d "$pkgdir/usr/share/pyhotspot"
  cp -r core ui widgets "$pkgdir/usr/share/pyhotspot/"

  # 2. Создаем "запускалку" в /usr/bin/
  install -d "$pkgdir/usr/bin"
  echo -e "#!/bin/sh\nexec python /usr/share/pyhotspot/core/main.py \"\$@\"" > "$pkgdir/usr/bin/pyhotspot"
  
  # 3. Даем права на исполнение
  chmod +x "$pkgdir/usr/bin/pyhotspot"

  CURRENT_USER="${SUDO_USER:-$USER}"

echo "Настройка прав для пользователя: $CURRENT_USER"

sudo tee /etc/sudoers.d/pyhotspot > /dev/null << EOF
$CURRENT_USER ALL=(ALL) NOPASSWD: /usr/bin/nmcli
$CURRENT_USER ALL=(ALL) NOPASSWD: /usr/sbin/rfkill
$CURRENT_USER ALL=(ALL) NOPASSWD: /usr/sbin/sysctl -w net.ipv4.ip_forward=1
$CURRENT_USER ALL=(ALL) NOPASSWD: /bin/systemctl start NetworkManager
$CURRENT_USER ALL=(ALL) NOPASSWD: /bin/systemctl daemon-reload
$CURRENT_USER ALL=(ALL) NOPASSWD: /bin/systemctl enable pyhotspot.service
$CURRENT_USER ALL=(ALL) NOPASSWD: /bin/systemctl disable pyhotspot.service
$CURRENT_USER ALL=(ALL) NOPASSWD: /bin/rm -f /etc/systemd/system/pyhotspot.service
EOF

sudo chmod 440 /etc/sudoers.d/pyhotspot
sudo chown root:root /etc/sudoers.d/pyhotspot

if sudo visudo -c -f /etc/sudoers.d/pyhotspot; then
    echo "Права настроены успешно"
else
    echo "Ошибка в файле sudoers — удаляем"
    sudo rm /etc/sudoers.d/pyhotspot
    exit 1
fi
}