New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@pirateship/cli

Package Overview
Dependencies
Maintainers
9
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pirateship/cli - npm Package Compare versions

Comparing version
0.3.6
to
0.3.7
+15
lib/scripts/wificountry.sh
#!/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 @@ });

{
"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",

@@ -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 @@ ```