Skip to content

Commit

Permalink
Add Makefile - part 2
Browse files Browse the repository at this point in the history
  • Loading branch information
yavincl committed Jun 8, 2021
1 parent 555d15f commit 2b82b03
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 34 deletions.
9 changes: 5 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ all:

install:
install -Dm755 routertools $(DESTDIR)$(BINDIR)/routertools
install -Dm644 systemd/routertoolsd-inet.service $(DESTDIR)$(PREFIX)/lib/systemd/system/routertoolsd-inet.service
install -Dm644 systemd/routertoolsd-wifi@.service $(DESTDIR)$(PREFIX)/lib/systemd/system/routertoolsd-wifi@.service
install -Dm644 README.md $(DESTDIR)$(PREFIX)/share/doc/x86routertools/README.md
[ -d /etc/routertools.d ] || routertools reset-cfg
install -Dm644 systemd/routertoolsd-inet.service $(DESTDIR)$(PREFIX)/lib/systemd/system/routertoolsd-inet.service
install -Dm644 systemd/routertoolsd-wifi@.service $(DESTDIR)$(PREFIX)/lib/systemd/system/routertoolsd-wifi@.service
install -Dm644 README.md $(DESTDIR)$(PREFIX)/share/doc/x86routertools/README.md
@- routertools -qF
@echo "If you get error 1 (ignored), it's normal. Routertools is installed."
uninstall:
rm -f $(DESTDIR)$(BINDIR)/routertools
[ ! -f /lib/systemd/system/routertoolsd-inet.service ] || rm -f $(DESTDIR)$(PREFIX)/lib/systemd/system/routertoolsd-inet.service
Expand Down
23 changes: 10 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ x86routertools comes with many verbs that can be used to get information on the

For example, you can check what MCS rates your phone is using on the connection, to measure the quality of the service it is getting:
* Get the MAC address of the device by looking at the list of connected devices:
* `routertools ls`
* `$ routertools ls`
* Then, you can pull up the real-time rate display with the AP's interface name:
* `routertools display-rates wlan0 aa:bb:cc:dd:ee:ff`
* `$ routertools display-rates wlan0 aa:bb:cc:dd:ee:ff`

You can also toggle many runtime options of a wireless interface. For example, to turn on LNA mixing on ath9k cards (the daemon can do this for you, too):
* `routertools lnamix-on wlan0`
* `# routertools lnamix-on wlan0`
* Or, to set it on all APs on the system:
* `routertools lnamix-on`
* `# routertools lnamix-on`

Calling `routertools --help` should be enough to get you a full, descriptive list of commands.

Expand Down Expand Up @@ -79,13 +79,10 @@ x86routertools is normally installed to `/usr/bin`. Other necessary directories

To install it on your system:
* Clone the repository somewhere:
* `git clone https://github.com/yagoplx/x86routertools.git`
* `cd x86routertools`
* Move the files around:
* `cp -v routertools /usr/bin/`
* `cp -v systemd/* /etc/systemd/system/`
* Populate the configuration directories:
* `routertools reset-cfg`
* `$ git clone https://github.com/yagoplx/x86routertools.git`
* `$ cd x86routertools`
* Run make install:
* `# make install`

It should be ready for configuration, though you may also want to run a `systemctl daemon-reload` if you want to try out the daemon right away.

Expand All @@ -96,8 +93,8 @@ Each wireless interface should have two files in there: a interfacename.conf, an
As for the internet facing interface, you should set up scripts to set them up and down at `/etc/routertools.d/scripts`. The default is to just call the Arch Linux pppoe-start and pppoe-stop commands for PPPoE. The daemon will call the stop script when it restarts the interface, and then the start script. The command line tools also can use these scripts as well.

You can have the daemon start on boot for the standard wifi router experience:
* `sudo systemctl enable routertoolsd-inet`
* `sudo systemctl enable routertoolsd-wifi@interface_name`
* `# systemctl enable routertoolsd-inet`
* `# systemctl enable routertoolsd-wifi@interface_name`

#### <a name="cfgopt"></a>Configuration options
Configuration is system-wide and is done via files in `/etc/routertools.d`
Expand Down
36 changes: 19 additions & 17 deletions routertools
Original file line number Diff line number Diff line change
Expand Up @@ -287,15 +287,19 @@ resetcfg(){
# Resets all configuration in /etc/routertools.d
checksu || crit_error "You must be root to execute this function."

echo "This will delete EVERYTHING under /etc/routertools.d"
echo "Are you sure you want to do this?"
echo "[Enter-> Continue] [Ctrl+C-> Cancel]"

# "enter" detection
read x
unset x

rm -r /etc/routertools.d
if [[ -d /etc/routertools.d ]]; then
echo "This will delete EVERYTHING under /etc/routertools.d"
echo "Are you sure you want to do this?"
echo "[Enter-> Continue] [Ctrl+C-> Cancel]"

# "enter" detection
read x
unset x

rm -r /etc/routertools.d
fi

echo "Initializing configuration..."
initfs
initfs_daemon_cfg
return $?
Expand All @@ -317,9 +321,9 @@ initfs(){
fi

if [[ ! -d ${PREFIX}routertools.d ]]; then
echo "Attempting to create ${PREFIX}routertools.d"
echo "Populating ${PREFIX}routertools.d..."
mkdir ${PREFIX}routertools.d || crit_error
echo "Creating basic directory structure in ${PREFIX}routertools.d"
ifv echo "Creating basic directory structure in ${PREFIX}routertools.d"
mkdir ${PREFIX}routertools.d/wifi-access-points
mkdir ${PREFIX}routertools.d/scripts

Expand All @@ -330,15 +334,15 @@ initfs(){
initfile ${PREFIX}routertools.d/x86routertools.conf
initfile ${PREFIX}routertools.d/wifi-access-points/example_interface.conf

echo "Setting permissions on ${PREFIX}routertools.d"
ifv echo "Setting permissions on ${PREFIX}routertools.d"
chmod 700 ${PREFIX}routertools.d/*
chmod og+xr ${PREFIX}routertools.d
chmod og+xr ${PREFIX}routertools.d/x86routertools.conf
chmod og+xr ${PREFIX}routertools.d/wifi-access-points/example_interface.conf
chmod og+xr ${PREFIX}routertools.d/wifi-access-points

echo "Downloading example hostapd.conf from w1.fi"
wget https://w1.fi/cgit/hostap/plain/hostapd/hostapd.conf -O ${PREFIX}routertools.d/wifi-access-points/example_interface_hostapd.conf || error "Couldn't download example configuration file."
echo "Downloading example hostapd.conf from w1.fi. Please wait..."
wget -q https://w1.fi/cgit/hostap/plain/hostapd/hostapd.conf -O ${PREFIX}routertools.d/wifi-access-points/example_interface_hostapd.conf || error "Couldn't download example configuration file."

# Hostapd file may contain plaintext passwords
chmod -R 700 ${PREFIX}routertools.d/wifi-access-points/example_interface_hostapd.conf
Expand Down Expand Up @@ -592,7 +596,7 @@ initfs_daemon_cfg(){
echo "daemon_wifi_wait_for_internet_timeout=120" >> $f
echo "" >> $f
echo "# daemon_ath9k_recalibrate_every -> a number in seconds." >> $f
echo "# if running the wifi daemon and wifi_driver for that interface includes ath9k, ath9k-recalibrate will be run every X seconds."
echo "# if running the wifi daemon and wifi_driver for that interface includes ath9k, ath9k-recalibrate will be run every X seconds." >> $f
echo "# recommended is hourly (3600). Set to 0 to disable." >> $f
echo "daemon_ath9k_recalibrate_every=0" >> $f
echo "" >> $f
Expand Down Expand Up @@ -1441,7 +1445,6 @@ load_prefs_error(){
echo "I'm going to generate them now."
rm -r /etc/routertools.d &>/dev/null
initfs
[[ -f /etc/routertools.d/daemon.conf ]] && _exit "Done. Try running x86routertools again."
fi

}
Expand All @@ -1453,7 +1456,6 @@ load_prefs_daemon_error(){
else
echo "Generating new daemon.conf in /etc/routertools.d/ ..."
initfs_daemon_cfg
_exit "Done. Try running x86routertools again."
fi

}
Expand Down

0 comments on commit 2b82b03

Please sign in to comment.