Skip to content

Commit

Permalink
remove nhweb and google group word count stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel1111 committed Feb 13, 2019
1 parent a89a5f9 commit 3487061
Show file tree
Hide file tree
Showing 64 changed files with 13 additions and 9,492 deletions.
17 changes: 3 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ SlackRtm/slackrtm/libslackrtm_static.a: $(wildcard SlackRtm/cpp/*)
$(BIN_OUT)nh-slack: $(BUILD_DIR)nh-slack.o $(BUILD_DIR)irc.o $(OBJS_BASE) SlackRtm/slackrtm/libslackrtm_static.a
g++ -lmosquitto -lrt -lpthread -lssl -lcrypto -lz -ljson-c -lcurl -lwebsockets -o $(BIN_OUT)nh-slack $(BUILD_DIR)nh-slack.o $(BUILD_DIR)irc.o SlackRtm/slackrtm/libslackrtm_static.a $(OBJS_BASE)

$(BIN_OUT)nh-mail: $(BUILD_DIR)nh-mail.o $(BUILD_DIR)CEmailProcess.o $(BUILD_DIR)INIReader.o $(BUILD_DIR)ini.o $(BUILD_DIR)CLogging.o $(OBJS_DBLIB)
$(BIN_OUT)nh-mail: $(BUILD_DIR)nh-mail.o $(BUILD_DIR)CEmailProcess.o $(BUILD_DIR)INIReader.o $(BUILD_DIR)ini.o $(BUILD_DIR)CLogging.o
g++ -lmysqlclient -lmosquitto -o $(BIN_OUT)nh-mail $(BUILD_DIR)nh-mail.o $(BUILD_DIR)CEmailProcess.o $(BUILD_DIR)INIReader.o $(BUILD_DIR)ini.o $(BUILD_DIR)CLogging.o $(OBJS_DBLIB)

$(BIN_OUT)nh-macmon: $(BUILD_DIR)nh-macmon.o $(BUILD_DIR)CMacmon.o $(OBJS_BASE) $(OBJS_DBLIB)
Expand All @@ -81,20 +81,10 @@ $(BIN_OUT)plan: $(GOPLAN_BASE)plan.go
export GOPATH=$(shell pwd)/$(GOPLAN_BASE)vendor ; \
go build -o $(BIN_OUT)plan $(GOPLAN_BASE)plan.go

web/nhweb/build/script/custom.js: $(wildcard web/nhweb/source/class/custom/*)
sh nhweb.sh

nh-web: web/nhweb/build/script/custom.js

web2: nh-web db/lib/CNHDBAccess.php web/vend.php web/db.php web/wiki/wikiauth.php
mkdir -p website/public/nhweb/
web2: db/lib/CNHDBAccess.php web/vend.php web/db.php web/wiki/wikiauth.php
mkdir -p website/public/wiki/
mkdir -p website/www_secure/
cp db/lib/CNHDBAccess.php website/www_secure/
rsync -r --exclude=. web/nhweb/build/script website/public/nhweb/
rsync -r --exclude=. web/nhweb/build/resource website/public/nhweb/
cp web/nhweb/build/index.html website/public/nhweb/index.html
rsync -r --exclude=. -r web/rpcservice website/public/
rsync -r --exclude=. -r web/status website/public/
rsync -r --exclude=. -r web/stats website/public/
cp web/vend.php website/public/
Expand All @@ -106,7 +96,7 @@ web2: nh-web db/lib/CNHDBAccess.php web/vend.php web/db.php web/wiki/wikiauth.ph
$(BUILD_DIR)CNHmqtt.o: $(SRC_DIR)CNHmqtt.cpp $(SRC_DIR)CNHmqtt.h
$(CC) $(CFLAGS) -c $(SRC_DIR)CNHmqtt.cpp $(CC_OUT)

$(BUILD_DIR)nh-mail.o: $(SRC_DIR)nh-mail.cpp $(SRC_DIR)nh-mail.h db/lib/CNHDBAccess.h
$(BUILD_DIR)nh-mail.o: $(SRC_DIR)nh-mail.cpp $(SRC_DIR)nh-mail.h
$(CC) $(CFLAGS) -c $(SRC_DIR)nh-mail.cpp $(CC_OUT)

$(BUILD_DIR)CNHmqtt_irc.o: $(SRC_DIR)CNHmqtt_irc.cpp $(SRC_DIR)CNHmqtt_irc.h
Expand Down Expand Up @@ -214,7 +204,6 @@ $(BUILD_DIR)CDBValue.o: db/lib/CDBValue.cpp db/lib/CDBValue.cpp db/lib/CDBValue.
clean:
rm -fv build/*
rm -fv bin/*
rm -fv web/nhweb/build/script/custom.js
rm -rfv website/
cd SlackRtm ; make clean

Expand Down
7 changes: 1 addition & 6 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ This repository contains various parts of the Nottinghack instrumentation projec
* Temperature monitoring (nh-temperature.cpp). Cacti is used to graph the data, see https://github.com/NottingHack/Cacti-Scripts/ for the sctipts, or http://cacti.nottinghack.org.uk/graph_view.php for live graphs. The blue room, comfy area & studio sensors are connected to the LED matrix display (and directly reports to nh-temperature), the fridge temperature sensor is connecting to the blue room LED display, and reports the temperature to nh-temperature via nh-mini-matrix (UDP connection from the display to holly).

* Google group monitoring (nh-mail.cpp)
Fetchmail is configured to check holly's email account (which is subscribed to the Google group), and invoke nh-mail for every email received. This this then publishes the topic of the emails to MQTT, which is displayed on the two LED displays. Additionally, it is calculating email stats (word + email counts), available at http://lspace.nottinghack.org.uk/gg_wc/gg_word_count.php (still needs a fair bit of work).
Fetchmail is configured to check holly's email account (which is subscribed to the Google group), and invoke nh-mail for every email received. This this then publishes the topic of the emails to MQTT, which is displayed on the two LED displays.

* irccat (nh-irccat.cpp)
Allows some of the simpler IRC scripts stolen from London Hackspace (https://github.com/londonhackspace/irccat-commands) in the irccat/ directory to run.
Expand All @@ -24,8 +24,6 @@ Web stuff (web/ directory)
There is some miscellaneous web/php stuff in here:
* Auth.php - Wiki authentication plugin. This part is installed on the main Nottinghack web server, and talks to wikiauth.php on holly. Used to allow HMS logins to be used on the Wiki (wiki account gets auto-created on first login).

* gg_word_count_* - used to display the word counts stats generated by nh-mail; currently at http://lspace.nottinghack.org.uk/gg_wc/gg_word_count.php

* krb5_auth.php - Kerberos authentication - used by nh-web and the Wiki plugin

* vend.php - Show what's currently in the vending machine. Currently at http://lspace.nottinghack.org.uk/vend.php
Expand All @@ -34,9 +32,6 @@ There is some miscellaneous web/php stuff in here:

* status/ - Implementation of SpaceAPI (http://hackerspaces.nl/spaceapi/), see http://hackerspaces.me/

* nh-web.
Internal access only web application written using the qooxdoo Javascript framework, and now largely superseded by HMS. Allows members to be added/listed, PINs set, vending machine purchases and current balances to be viewed/amened. Will be removed once all its current functionality is in HMS. Client side GUI code is in nhweb/source/class/custom/*, server side database access is in rpcservice/services/class/qooxdoo/nhweb.php. For any client changes, needs the Qooxdoo 1.6 SDK to be in "./qooxdoo-1.6-sdk" (changes can be built by running "make web2" in the project root).

Database creation
=================
The database structure should match current "Release" version of HMS (https://github.com/NottingHack/hms), as the two projects share the same database on Holly (but access it using different usernames). An existing HMS-only database (e.g. one created by the HMS dev/setup script) can also be used by skipping the steps where noted.
Expand Down
36 changes: 5 additions & 31 deletions cpp/nh-mail.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
nh_mail::nh_mail(int argc, char *argv[])
{
log = NULL;
db = NULL;
string config_file = "";
config_file_parsed = false;
int c;
Expand Down Expand Up @@ -102,10 +101,7 @@ nh_mail::nh_mail(int argc, char *argv[])

log->dbg("mosq_server = " + mosq_server);
out << "" << mosq_port;
log->dbg("mosq_port = " + out.str());

db = new CNHDBAccess(get_str_option("mysql", "server", "localhost"), get_str_option("mysql", "username", "gatekeeper"), get_str_option("mysql", "password", "gk"), get_str_option("mysql", "database", "gk"), log);

log->dbg("mosq_port = " + out.str());
}

nh_mail::~nh_mail()
Expand All @@ -132,9 +128,6 @@ nh_mail::~nh_mail()
delete log;
log=NULL;
}

if (db != NULL)
delete db;
}

string nh_mail::get_str_option(string section, string option, string def_value)
Expand Down Expand Up @@ -167,10 +160,8 @@ int nh_mail::mosq_connect()
return -1;
}

mosquitto_connect_callback_set(mosq, nh_mail::connect_callback);
// mosquitto_message_callback_set(mosq, nh_mail::message_callback);

// int mosquitto_connect(struct mosquitto *mosq, const char *host, int port, int keepalive, bool clean_session);
mosquitto_connect_callback_set(mosq, nh_mail::connect_callback);

if(mosquitto_connect(mosq, mosq_server.c_str(), mosq_port, 300))
{
log->dbg("mosq_connnect failed!");
Expand All @@ -179,8 +170,8 @@ int nh_mail::mosq_connect()
return -1;
}
mosq_connected = true;
return 0;

return 0;
}

void nh_mail::connect_callback(struct mosquitto*, void *obj, int result)
Expand Down Expand Up @@ -237,10 +228,8 @@ int main(int argc, char *argv[])
string reply_to;
string body;
string body_processed;
int ggemail_id;
string err;
string searchstr;
unsigned int word_count = 0;

/* Read in email */
while (cin)
Expand Down Expand Up @@ -285,23 +274,8 @@ int main(int argc, char *argv[])
nh->message_send(nh->mqtt_topic + "/" + mail_from, mail_subject);
nh->message_loop();

if (ep.get_list_id() == "<nottinghack.googlegroups.com>")
{
/* Add to database */
nh->db->dbConnect();
nh->db->sp_log_ggemail (ep.get_subject(), body, reply_to, message_id, ep.get_from(), err, ggemail_id);

/* Get and save word count */
word_count = ep.get_msg_word_count(body, body_processed);
nh->db->sp_gg_set_auto_wc(ggemail_id, word_count, body_processed);
}

delete nh;
}

return 0;
}




8 changes: 3 additions & 5 deletions cpp/nh-mail.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "mosquitto.h"
#include "CLogging.h"
#include "inireader/INIReader.h"
#include "CNHDBAccess.h"

#define EXIT_TERMINATE 1
#define EXIT_RESET 2
Expand All @@ -22,15 +21,14 @@ class nh_mail
void dbg(string msg);
int message_send(string topic, string message);
int message_send(string topic, string message, bool no_debug);

int mosq_connect();

bool mosq_connected;
static string itos(int n);
int message_loop(void);
string mqtt_topic;
CNHDBAccess *db;


protected:
string mosq_server;
int mosq_port;
Expand Down
2 changes: 1 addition & 1 deletion db/database
Submodule database updated 33 files
+1 −1 procedures/fn_check_permission.sql
+39 −0 procedures/fn_tool_in_maintenance_slot.sql
+0 −119 procedures/sp_add_member.sql
+10 −10 procedures/sp_email_update.sql
+0 −63 procedures/sp_gg_get_address_id.sql
+0 −37 procedures/sp_gg_get_email.sql
+0 −56 procedures/sp_gg_set_auto_wc.sql
+0 −43 procedures/sp_gg_set_manual_wc.sql
+24 −23 procedures/sp_invoice_prepare.sql
+1 −1 procedures/sp_process_transaction_missed.sql
+1 −1 procedures/sp_process_transactions.sql
+84 −61 procedures/sp_tool_charge.sql
+0 −25 procedures/sp_tool_delete_google_channel.sql
+0 −22 procedures/sp_tool_get_google_channels.sql
+0 −23 procedures/sp_tool_get_google_info.sql
+96 −66 procedures/sp_tool_induct.sql
+10 −10 procedures/sp_tool_pledged_remain.sql
+33 −33 procedures/sp_tool_sign_off.sql
+85 −88 procedures/sp_tool_sign_on.sql
+1 −1 procedures/sp_transaction_log.sql
+3 −2 procedures/sp_transaction_update.sql
+3 −3 procedures/sp_vend_failure.sql
+0 −48 procedures/sp_web_change_password.sql
+0 −30 procedures/sp_web_group_add.sql
+0 −25 procedures/sp_web_group_add_member.sql
+0 −33 procedures/sp_web_group_del.sql
+0 −26 procedures/sp_web_group_delete_member.sql
+0 −34 procedures/sp_web_group_toggle_permission.sql
+0 −45 procedures/sp_web_login.sql
+0 −47 procedures/sp_web_set_password.sql
+0 −58 procedures/sp_web_set_vendprd.sql
+0 −37 procedures/sp_web_updateproduct.sql
+5 −5 procedures/sp_wiki_login.sql
5 changes: 0 additions & 5 deletions nhweb.sh

This file was deleted.

13 changes: 0 additions & 13 deletions vagrant_config/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ mysql -uroot -proot -e "grant select on instrumentation.* to 'inst_run'@'localho
mysql -uroot -proot -e "GRANT ALL ON *.* TO 'hms'@'localhost' IDENTIFIED BY '' WITH GRANT OPTION"
mysql -uroot -proot -e "FLUSH PRIVILEGES"

# echo "deb http://ftp.debian.org/debian jessie-backports main" >> /etc/apt/sources.list
apt-get update
apt-get -y install libmariadb-dev libjson-c-dev libcurl4-gnutls-dev libical-dev uuid-dev cmake libwebsockets-dev libutfcpp-dev libboost1.62-dev libpcap0.8-dev golang

Expand All @@ -34,15 +33,6 @@ sed -i -e 's/\/PATH\/TO\/KEYTAB/\/config\/nhweb.keytab/g' web/db.php
sed -i -e 's/hms_test\/web/inst\/web/g' web/db.php
chmod a+rw /config/nhweb.keytab

if [ ! -f 'qooxdoo-5.0.2-sdk.zip' ]; then
echo "Getting qooxdoo-5.0.2-sdk.zip..."
wget -q https://github.com/qooxdoo/qooxdoo/releases/download/release_5_0_2/qooxdoo-5.0.2-sdk.zip
echo "Unzipping qooxdoo-5.0.2-sdk.zip..."
unzip -q qooxdoo-5.0.2-sdk.zip
fi

# make nh-web web2

rm -rf /var/www/html/
ln -s /vagrant/website/public/ /var/www/html
ln -s /vagrant/website/www_secure/ /var/www/www_secure
Expand All @@ -59,9 +49,6 @@ echo "alias sql=\"mysql -proot -uroot instrumentation\"" > /home/vagrant/.bash_a

echo ""
echo "------------------------------------------------------------------------"
echo " **** nh-web should now be running at http://localhost:8000/nhweb/ **** "
echo " **** Login using username=Admin, password=admin **** "
echo " (all other accounts have the password \"password\")"
echo ""
echo "MySQL: username = root, password = root"
echo "kadmin: username = admin/admin, password = admin"
Expand Down
9 changes: 0 additions & 9 deletions web/gg_wc/gg_word_count.css

This file was deleted.

122 changes: 0 additions & 122 deletions web/gg_wc/gg_word_count.php

This file was deleted.

Loading

0 comments on commit 3487061

Please sign in to comment.