@pirateship/cli
Advanced tools
| #!/bin/bash | ||
| COUNTRY=$1 | ||
| if grep -q "^country=" /etc/wpa_supplicant/wpa_supplicant.conf ; then | ||
| sed -i --follow-symlinks "s/^country=.*/country=$COUNTRY/g" /etc/wpa_supplicant/wpa_supplicant.conf | ||
| else | ||
| sed -i --follow-symlinks "1i country=$COUNTRY" /etc/wpa_supplicant/wpa_supplicant.conf | ||
| fi | ||
| iw reg set "$COUNTRY" | ||
| if [ -f /run/wifi-country-unset ] && hash rfkill 2> /dev/null; then | ||
| rfkill unblock wifi | ||
| fi | ||
| echo $COUNTRY > /etc/rpi-wifi-country |
| #!/usr/bin/env node | ||
| var exec = require('child_process').exec; | ||
| var fs = require('fs') | ||
| module.exports = country => { | ||
| var availableCountries = []; | ||
| fs.readFile('/usr/share/zoneinfo/iso3166.tab', "utf-8", function(err, data) { | ||
| if (err) { | ||
| console.log("Error: unable to read the list of supported countries"); | ||
| return; | ||
| } | ||
| var lines = data.split("\n"); | ||
| lines = lines.splice(25, lines.length) | ||
| lines.forEach(line => { | ||
| var country = line.split("\t")[0] | ||
| if (country) { | ||
| availableCountries.push(country) | ||
| } | ||
| }) | ||
| if (!availableCountries.includes(country.toUpperCase())) { | ||
| console.log("Error: the country '" + country.toUpperCase() + "' is not supported."); | ||
| return; | ||
| } | ||
| var command = __dirname + "/scripts/wificountry.sh " + country.toUpperCase() | ||
| exec(command, (error, stdout, stderr) => { | ||
| if (error || stderr) { | ||
| console.log("Error: when trying to change the wifi country to '" + country.toUpperCase() + "'"); | ||
| console.log(error); | ||
| console.log(stderr); | ||
| return; | ||
| } | ||
| console.log("Success: the wifi country has been set to '" + country.toUpperCase() + "'"); | ||
| }); | ||
| }); | ||
| } |
+6
-1
@@ -18,3 +18,3 @@ #!/usr/bin/env node | ||
| command: 'wifi <ESSID> [password]', | ||
| description: 'changes hostname', | ||
| description: 'connects to a wifi network', | ||
| action: './lib/wifi.js' | ||
@@ -76,2 +76,7 @@ }, | ||
| action: './lib/bluetooth.js' | ||
| }, | ||
| { | ||
| command: 'wificountry <country>', | ||
| description: 'changes the wifi country', | ||
| action: './lib/wificountry.js' | ||
| } | ||
@@ -78,0 +83,0 @@ ] |
@@ -9,4 +9,5 @@ #!/bin/bash | ||
| rm -rf /etc/network/interfaces.d/* | ||
| rm -rf /etc/rpi-wifi-country | ||
| pirateship rename raspberrypi | ||
| systemctl disable hostapd || true | ||
| systemctl disable dnsmasq || true |
+32
-14
@@ -34,6 +34,6 @@ #!/usr/bin/env node | ||
| var system_wpa_supplicant = '/etc/wpa_supplicant/wpa_supplicant.conf' | ||
| var system_wifi_country = '/etc/rpi-wifi-country' | ||
| if (password === undefined) { | ||
| var network = ` | ||
| network={ | ||
| var network = `network={ | ||
| ssid="` + ESSID + `" | ||
@@ -48,9 +48,18 @@ key_mgmt=NONE | ||
| wpa_supplicant_conf = data + network | ||
| fs.writeFile(system_wpa_supplicant, wpa_supplicant_conf, 'utf8', err => { | ||
| if (err) { | ||
| console.log(err) | ||
| var wifiCountry = "US" | ||
| fs.readFile(system_wifi_country, (err, countryData) => { | ||
| if (countryData) { | ||
| wifiCountry = countryData.toString().trim(); | ||
| } | ||
| ifdownup('open wifi network') | ||
| }); | ||
| data = data.toString().trim() | ||
| wpa_supplicant_conf = data + "\ncountry=" + wifiCountry + "\n" + network | ||
| fs.writeFile(system_wpa_supplicant, wpa_supplicant_conf, 'utf8', err => { | ||
| if (err) { | ||
| console.log(err) | ||
| } | ||
| ifdownup('open wifi network') | ||
| }); | ||
| }) | ||
| }); | ||
@@ -70,9 +79,18 @@ } else { | ||
| wpa_supplicant_conf = data + stdout | ||
| fs.writeFile(system_wpa_supplicant, wpa_supplicant_conf, 'utf8', err => { | ||
| if (err) { | ||
| console.log(err) | ||
| var wifiCountry = "US" | ||
| fs.readFile(system_wifi_country, (err, countryData) => { | ||
| if (countryData) { | ||
| wifiCountry = countryData.toString().trim(); | ||
| } | ||
| ifdownup('password network') | ||
| }) | ||
| data = data.toString().trim() | ||
| wpa_supplicant_conf = data + "\ncountry=" + wifiCountry + "\n" + stdout | ||
| fs.writeFile(system_wpa_supplicant, wpa_supplicant_conf, 'utf8', err => { | ||
| if (err) { | ||
| console.log(err) | ||
| } | ||
| ifdownup('password network') | ||
| }) | ||
| }); | ||
| }); | ||
@@ -79,0 +97,0 @@ }); |
+1
-1
| { | ||
| "name": "@pirateship/cli", | ||
| "version": "0.3.6", | ||
| "version": "0.3.7", | ||
| "description": "Thin command-line interface for Raspberry Pi low level configuration.", | ||
@@ -5,0 +5,0 @@ "main": "cli.js", |
+3
-3
@@ -9,5 +9,4 @@ # Usage | ||
| -h, --help output usage information | ||
| -h, --help output usage information | ||
| Commands: | ||
@@ -27,3 +26,4 @@ | ||
| version returns the version of pirateship command | ||
| wifi <ESSID> [password] changes hostname | ||
| wifi <ESSID> [password] connects to a wifi network | ||
| wificountry <country> changes the wifi country | ||
| * temporary catch all | ||
@@ -30,0 +30,0 @@ ``` |
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
58973
4.52%53
3.92%529
10.9%12
9.09%14
7.69%