Skip to content

Commit 66f96ac

Browse files
committed
new install
1 parent 662218b commit 66f96ac

File tree

3 files changed

+62
-32
lines changed

3 files changed

+62
-32
lines changed

bootstate/install-bootstate.sh

100644100755
+48-22
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,68 @@
11
#!/bin/sh
22
#
3-
echo "Installing bootstate ..."
3+
4+
TARGET="$1"
5+
if [ -z "$TARGET" ]; then
6+
echo "Usage: $0 <TARGET>"
7+
exit 1
8+
fi
9+
10+
echo "Installing mPower bootstate ... to $TARGET"
11+
12+
WORK_DIR=`mktemp -d -p "$DIR"`
13+
SSH_PARAMS="-o PubkeyAcceptedKeyTypes=+ssh-rsa -o KexAlgorithms=+diffie-hellman-group1-sha1 -o HostKeyAlgorithms=+ssh-dss -o Ciphers=+aes256-cbc -o StrictHostKeyChecking=accept-new"
14+
SCP_PARAMS="$SSH_PARAMS"
415

516
scriptdir=/var/etc/persistent/bootstate
17+
applyscript="$scriptdir/apply-bootstate.sh"
18+
19+
ssh $SSH_PARAMS ubnt@$TARGET "mkdir -p $scriptdir"
20+
wget -q https://raw.githubusercontent.com/magcode/mpower-tools/master/bootstate/apply-bootstate.sh -O $WORK_DIR/apply-bootstate.sh
21+
scp $SCP_PARAMS $WORK_DIR/apply-bootstate.sh ubnt@$TARGET:$scriptdir
22+
ssh $SSH_PARAMS ubnt@$TARGET "chmod 755 $applyscript"
623

7-
mkdir -p $scriptdir
824
config="$scriptdir/bootstate.cfg"
9-
applyscript="$scriptdir/apply-bootstate.sh"
10-
poststartscript="sleep 60; $applyscript"
11-
poststart=/etc/persistent/rc.poststart
1225

13-
wget --no-check-certificate -q https://raw.githubusercontent.com/magcode/mpower-tools/master/bootstate/apply-bootstate.sh -O $applyscript
14-
chmod 775 $applyscript
1526

16-
if [ ! -f $config ]; then
17-
echo "$config not found, creating it ..."
18-
export PORTS=`cat /etc/board.inc | grep feature_power | sed -e 's/.*\([0-9]\+\);/\1/'`
19-
touch $config
27+
28+
if ssh $SSH_PARAMS ubnt@$TARGET "test -f '$config'" 2>/dev/null; then
29+
echo "$config exists, not touching"
30+
else
31+
PORTS=`ssh $SSH_PARAMS ubnt@$TARGET "cat /etc/board.inc | grep feature_power | sed -e 's/.*\([0-9]\+\);/\1/'" 2>/dev/null`
32+
echo "Found $PORTS ports"
33+
34+
ssh $SSH_PARAMS ubnt@$TARGET "touch $config"
2035
for i in $(seq $PORTS)
2136
do
22-
echo "vpower.$i.relay=on" >> $config
37+
ssh $SSH_PARAMS ubnt@$TARGET "echo 'vpower.$i.relay=on' >> $config"
2338
done
39+
echo "Config file created: $config"
2440
fi
2541

26-
if [ ! -f $poststart ]; then
42+
43+
44+
poststart=/etc/persistent/rc.poststart
45+
poststartscript="sleep 60; $applyscript"
46+
47+
48+
# create poststart file if not exists
49+
50+
if ssh $SSH_PARAMS ubnt@$TARGET "test -f '$poststart'" 2>/dev/null; then
51+
echo "$poststart exists already"
52+
else
2753
echo "$poststart not found, creating it ..."
28-
touch $poststart
29-
echo "#!/bin/sh" >> $poststart
30-
chmod 755 $poststart
54+
ssh $SSH_PARAMS ubnt@$TARGET "echo '#!/bin/sh' >> $poststart"
55+
ssh $SSH_PARAMS ubnt@$TARGET "chmod 755 $poststart"
3156
fi
3257

33-
if grep -q "$poststartscript" "$poststart"; then
34-
echo "Found $poststart entry. File will not be changed"
58+
# add entry to poststart file if not exists
59+
if ssh $SSH_PARAMS ubnt@$TARGET "grep -q '$poststartscript' '$poststart'" 2>/dev/null; then
60+
echo "Found startscript entry. File will not be changed"
3561
else
36-
echo "Adding start command to $poststart"
37-
echo -e "$poststartscript" >> $poststart
62+
echo "Adding start command to $poststart"
63+
ssh $SSH_PARAMS ubnt@$TARGET "echo -e '$poststartscript' >> $poststart"
3864
fi
3965

40-
echo "Done!"
41-
cfgmtd -w -p /etc/
66+
ssh $SSH_PARAMS ubnt@$TARGET "cfgmtd -w -p /etc/"
67+
4268
echo "Adapt your settings in '$config' and call '$applyscript' afterwards."

mqtt/client/install-client.sh

100644100755
+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ LOCALDIR="/var/etc/persistent/mqtt"
1212
LOCALSCRIPTDIR=$LOCALDIR/client
1313
BASEURL="https://raw.githubusercontent.com/magcode/mpower-tools/master/mqtt"
1414
SSH_PARAMS="-o PubkeyAcceptedKeyTypes=+ssh-rsa -o KexAlgorithms=+diffie-hellman-group1-sha1 -o HostKeyAlgorithms=+ssh-dss -o Ciphers=+aes256-cbc -o StrictHostKeyChecking=accept-new"
15-
SCP_PARAMS="-O $SSH_PARAMS"
15+
SCP_PARAMS="$SSH_PARAMS"
1616

1717
echo "Installing mPower MQTT v2 ... to $TARGET"
1818
wget --no-check-certificate -q $BASEURL/libmosquitto.so.1?raw=true -O $WORK_DIR/libmosquitto.so.1

mqtt/client/readme.md

+13-9
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,23 @@ Use at your own risk!
77

88
# Installation
99

10-
**Attention! Automated installation using the script below is broken at the moment. You need to copy files manually**
11-
12-
(Reason is most likely because the mpower firmware/wget does not support newer TLS/SLL protocols required by github.)
10+
A linux system is required to install the MQTT client into your mPower.
11+
First add your public key to the mPower device.
12+
```
13+
ssh-copy-id -o KexAlgorithms=+diffie-hellman-group1-sha1 -o Ciphers=+aes256-cbc -o HostKeyAlgorithms=+ssh-dss -i ~/.ssh/id_rsa ubnt@<mpowerhost>
14+
```
1315

14-
Use a SSH client and connect to your mPower device.
15-
Internet access is required to use the automated installation process. If you don't have internet access you need to perform all steps of [install-client.sh](https://github.com/magcode/mpower-tools/blob/master/mqtt/client/install-client.sh) manually.
16+
If that works fine, execute the following commands on your linux machine:
17+
```
18+
wget -q https://raw.githubusercontent.com/magcode/mpower-tools/refs/heads/master/mqtt/client/install-client.sh
19+
chmod 777 install-client.sh
20+
./install-client.sh <mpowerhost>
21+
```
1622

17-
Enter the following commands
23+
Now SSH into your mPower, change `mqtt.cfg`, `mpower-pub.cfg`, `led.cfg` and "save"
1824

1925
```
20-
mkdir /var/etc/persistent/mqtt
21-
wget --no-check-certificate -q https://raw.githubusercontent.com/magcode/mpower-tools/master/mqtt/client/install-client.sh -O /var/etc/persistent/mqtt/install-client.sh;chmod 755 /var/etc/persistent/mqtt/install-client.sh;/var/etc/persistent/mqtt/install-client.sh
22-
26+
ssh <mpowerhost>
2327
save
2428
reboot
2529
```

0 commit comments

Comments
 (0)