Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...











































This is procedure to backup Open Enventory database and restore it later on the same server or migrating to a different server
.xz at the end of the file as above.-v : verbose, give more info[/path/backup-database] and [/path/backup-user]: any path and filenamemysqldump -u [user] -p [database] > [Path]/[backup_filename].sqlmysqldump -u [user] -p [database] | xz > [Path]/[backup_filename].sql.xzmysqldump -u [user] -p mysql > [Path]/[user_backup_filename].sqlunxz -vk [/path/backup-database].sql.xzmysql -u root -p [database-name] < [/path/backup-database].sql #for database restore
mysql -u root -p mysql < [/path/backup-user].sql #for users restore, this might not work for mariabd 10.4+ /Applications/XAMPP/xamppfiles/bin/mysqldump -u [user] -p [database] > [Path]/[backup_filename].sql/Applications/XAMPP/xamppfiles/bin/mysqldump -u [user] -p mysql > [Path]/[user_backup_filename].sql/Applications/XAMPP/xamppfiles/bin/mysql -u root -p [database-name] < [/path/to/backup-database].sql #for database restore
/Applications/XAMPP/xamppfiles/bin/mysql -u root -p mysql < [/path/to/backup-user].sql #for users restore, this might not work for mariabd 10.4+
c:\Programs\XAMPP\mysql\bin\mysqldump -u [user] -p [database] > [Path]/[backup_filename].sqlc:\Programs\XAMPP\mysql\bin\mysqldump -u [user] -p mysql > [Path]/[user_backup_filename].sqlc:\Programs\XAMPP\mysql\bin\mysql -u root -p [database-name] < [/path/to/backup-database].sql #for database restore
c:\Programs\XAMPP\mysql\bin\mysql -u root -p mysql < [/path/to/backup-user].sql #for users restore, this might not work for mariabd 10.4+vim mariadb_user_backup.sh#!/bin/sh
# This bash script is used to save users and permission from mysql database.
# Ref: https://stackoverflow.com/a/57878326
# explanation: https://wisdmlabs.com/blog/migrate-mysql-users-one-server-another/
HOSTNAME="localhost"
logininfo="-u root -pPASSWORD"
outfile="/path/oe_backup-user-$(date +\%Y\%m\%d).sql"
# The line below will save all users except 'root', empty name and specified ones
mysql ${logininfo} -B -N -e "SELECT CONCAT('\'',user,'\'@\'',host,'\'') from user where user != 'root' AND user != '' AND user not like 'auto%'" mysql | \
while read uh
do
echo "SHOW GRANTS FOR ${uh};"
done | mysql ${logininfo} -B -N | sed -e 's/$/;/' > ${outfile}chmod u+x mariadb_user_backup.sh./mariadb_user_backup.shmysql_upgrade # Upgrade MySQL data
systemctl restart mariadb # Restart mariadbquick intro on how to start using Electronic Lab Notebook in Open Enventory
How to install open enventory on Raspbian
Below are some additional SQL commands that can give you some info that are not possible from inside Open Enventory
sudo apt-get update
sudo apt-get upgrade sudo apt-get install mariadb-server-10.0sudo apt-get install -y php-mysql php-gd php-mbstring php-pear ghostscript imagemagick
sudo service apache2 restartsudo mysql_secure_installation
sudo service apache2 restart
sudo service mariadb restart
sudo mysql -u root -p
MariaDB [(none)]> USE mysql;
MariaDB [mysql]> UPDATE user SET plugin='mysql_native_password' WHERE User='root';
MariaDB [mysql]> FLUSH PRIVILEGES;
MariaDB [mysql]> exit;
sudo service mariadb restartcd ~/Downloads/
wget https://sourceforge.net/projects/enventory/files/open_enventory_2019-07-24.zip
unzip open_enventory_2019-07-24.zip
sudo mkdir /var/www/html/oe
sudo cp -r ~/Downloads/open_enventory_2019-07-24/. /var/www/html/oeifconfigsudo nano /var/www/html/oe/.htaccesssudo nano /etc/apache2/sites-available/000-default.confsudo service apache2 restartsudo npm install --unsafe-perm -g ngrokngrok http 80define("ban_duration",1800);
define("login_max_retries",4);define("ban_duration",300);
define("login_max_retries",10);


LIKE 'FH-2206%' would mean find anything with storage name ending with FH-2206lib_customization.your-school-name.php after $default_g_settings["order_system"]="fundp";:LIKE 'FH-2206%' would mean find anything with storage name ending with FH-2206
$allowed_per_page=array(10,25,50,100,-1);
$defaultCurrency="EUR";$allowed_per_page=array(10,25,50,100,500,1000,-1);
$defaultCurrency="USD";memory_limit = xxxMmemory_limit = xxxMsudo yum install php-gd
sudo yum install php-mbstringsudo systemctl restart httpd...
FocusInput(“xxxxxxx”);
......
FocusInput(“barcode”);
...if ($db_name=="") {
$db_name="storage";if ($db_name=="") {
$db_name="";<br><form id=\"login\" name=\"login\" method=\"post\" action=\"index.php?".getSelfRef(array("~script~","table"))."\">
<table id=\"login\" class=\"noborder blind\">
<tr><td colspan=\"2\">".s("please_logon_to1")."</td></tr>
<tr><td>".s("database")."</td><td><input type=\"text\" name=\"db_name\" id=\"db_name\" value=".fixStr(strip_tags($db_name),true)." size=\"16\"></td></tr>
<tr><td colspan=\"2\">".s("please_logon_to2")."</td></tr>
<tr><td>".s("db_user").":</td><td><input type=\"text\" name=\"user\" id=\"user\"<br><form id=\"login\" name=\"login\" method=\"post\" action=\"index.php?".getSelfRef(array("~script~","table"))."\">
<table id=\"login\" class=\"noborder blind\">
<tr><td colspan=\"2\">".s("please_logon_to1")."</td></tr>
<tr><td>".s("database")."</td><td><input type=\"text\" name=\"db_name\" id=\"db_name\" autofocus value=".fixStr(strip_tags($db_name),true)." size=\"16\"></td></tr>
<tr><td colspan=\"2\">".s("please_logon_to2")."</td></tr>
<tr><td>".s("db_user").":</td><td><input type=\"text\" name=\"user\" id=\"user\"function printDymoLabel() {
var url="editWin.php?mode=print_label&table="+table; window.open(url,Number(new Date()),"height=450,width=300,scrollbars=yes");
}function printDymoLabel() {
// First label:
var url="editWin.php?mode=print_label&table=chemical_storage1";
var window1=window.open(url,Number(new Date()),"height=300,width=200,scrollbars=yes");
setTimeout(function(){ window1.close() }, 30000); // this will automatically close this pop-up window in 30s;
// Second label:
var url="editWin.php?mode=print_label&table=chemical_storage2";
var window2=window.open(url,Number(new Date()),"height=300,width=200,scrollbars=yes");
window2.moveby(400,0); // this will move this window to the right, same vertical height so that it does not overlap the previous window;
setTimeout(function(){ window2.close() }, 30000); // this will automatically close this pop-up window in 30s;
}sudo systemclt restart httpd.servicecase "dymo":
$retval.="<a id=\"dymo\" href=\"javascript:void(0);\" class=\"imgButtonSm\" title=".fixStr(s("print_dymo_label"))." style=\"display:none\" onClick=\"….case "dymo":
$retval.="<a id=\"dymo\" href=\"javascript:void(0);\" class=\"imgButtonSm\" title=".fixStr(s("print_dymo_label"))." onClick=\"…SELECT * FROM storageSELECT * FROM chemical_storage WHERE storage_id=1UPDATE chemical_storage SET storage_id=9 WHERE storage_id=1SELECT * FROM chemical_storage WHERE borrowed_by_person_id=8UPDATE chemical_storage SET borrowed_by_person_id=NULL WHERE borrowed_by_person_id=8SELECT * FROM chemical_storage WHERE owner_person_id=7UPDATE chemical_storage SET owner_person_id=NULL WHERE owner_person_id=7SELECT person_id FROM person WHERE username='julia'SELECT storage_id FROM storage WHERE storage_name LIKE 'FH-2206%'SELECT * FROM chemical_storage
WHERE owner_person_id=15 AND storage_id NOT LIKE 18UPDATE chemical_storage
SET owner_person_id='NULL'
WHERE owner_person_id=15 AND storage_id NOT LIKE 18SELECT storage_name,storage_id
FROM storage
WHERE storage_id IN
(SELECT storage_id
FROM chemical_storage
WHERE owner_person_id in
(SELECT person_id FROM person WHERE username='mingzhao')
)
GROUP BY storage_nameUPDATE chemical_storage
SET owner_person_id=null
WHERE owner_person_id=13 AND storage_id IN (19,7,5,4,12,8)SELECT chemical_storage_barcode
FROM chemical_storage
WHERE chemical_storage_disabled IS NULL AND chemical_storage_barcode != ""
GROUP BY chemical_storage_barcode
HAVING Count(*) > 1;SELECT molecule_id,
chemical_storage_id,
chemical_storage_created_when,
chemical_storage_created_by,
chemical_storage_barcode
FROM chemical_storage
WHERE chemical_storage_barcode IN
(SELECT chemical_storage_barcode
FROM chemical_storage
WHERE chemical_storage_disabled IS NULL AND chemical_storage_barcode != ""
GROUP BY chemical_storage_barcode
HAVING Count(*) > 1
) AND
chemical_storage_created_by = "user1" AND
chemical_storage_created_when > '2019-08-16 18:00:00'
ORDER BY chemical_storage_barcode;mysql –u root -pshow databases;
use test;truncate table chemical_storage;
truncate table cache;
truncate table change_notify;alter table chemical_storage auto_increment=1exitsystemctl restart httpd mariadbmysql –u root -pshow databases;
use test;UPDATE chemical_storage
SET chemical_storage_barcode=trim(trailing cast("\n" as binary)
FROM chemical_storage_barcode);exitsystemctl restart httpd mariadbmysql –u root -pshow databases;
use test;select storage_name, storage_id,
concat(concat(92, lpad(storage_id, 5, 0)),
(10 - ((9*3 + 2 +
substring(cast(concat(92, lpad(storage_id, 5, 0)) as char), 3, 1)*3 +
substring(cast(concat(92, lpad(storage_id, 5, 0)) as char), 4, 1)*1 +
substring(cast(concat(92, lpad(storage_id, 5, 0)) as char), 5, 1)*3 +
substring(cast(concat(92, lpad(storage_id, 5, 0)) as char), 6, 1)*1 +
substring(cast(concat(92, lpad(storage_id, 5, 0)) as char), 7, 1)*3
) % 10)
) % 10)
as new_barcode from storage;update storage
set storage_barcode=cast(
concat(concat(92, lpad(storage_id, 5, 0)),
(10 -
((9*3 + 2 +
substring(cast(concat(92, lpad(storage_id, 5, 0)) as char), 3, 1)*3 +
substring(cast(concat(92, lpad(storage_id, 5, 0)) as char), 4, 1)*1 +
substring(cast(concat(92, lpad(storage_id, 5, 0)) as char), 5, 1)*3 +
substring(cast(concat(92, lpad(storage_id, 5, 0)) as char), 6, 1)*1 +
substring(cast(concat(92, lpad(storage_id, 5, 0)) as char), 7, 1)*3
) % 10
)
) % 10)
as binary)
where storage_barcode is NULL or storage_barcode='';exit;mysql –u root -pshow databases;
use test;select username, person_id,
concat(concat(91, lpad(person_id, 5, 0)),
(10 -
((9*3 + 1 +
substring(cast(concat(91, lpad(person_id, 5, 0)) as char), 3, 1)*3 +
substring(cast(concat(91, lpad(person_id, 5, 0)) as char), 4, 1)*1 +
substring(cast(concat(91, lpad(person_id, 5, 0)) as char), 5, 1)*3 +
substring(cast(concat(91, lpad(person_id, 5, 0)) as char), 6, 1)*1 +
substring(cast(concat(91, lpad(person_id, 5, 0)) as char), 7, 1)*3
) % 10)
) % 10
)
as new_barcode from person;update person
set person_barcode=cast(
concat(concat(91, lpad(person_id, 5, 0)),
(10 -
((9*3 + 1 +
substring(cast(concat(91, lpad(person_id, 5, 0)) as char), 3, 1)*3 +
substring(cast(concat(91, lpad(person_id, 5, 0)) as char), 4, 1)*1 +
substring(cast(concat(91, lpad(person_id, 5, 0)) as char), 5, 1)*3 +
substring(cast(concat(91, lpad(person_id, 5, 0)) as char), 6, 1)*1 +
substring(cast(concat(91, lpad(person_id, 5, 0)) as char), 7, 1)*3
) % 10)
) % 10) as binary
)
where person_barcode is NULL or person_barcode='';exit;vi /var/www/html/oe/lib_output.phpcase "storage":
if ($row["db_id"]==-1
|| $g_settings["order_system"]=="fundp" // fundp wants all to see the exact location
|| $db_user == ROOT) {
$retval=joinifnotempty(
array($row["storage_name"],
ifnotempty(s("compartment_short")." ",$row["compartment"]) // Fach X
)
);
}
else {
$retval=$row["show_db_beauty_name"];
} case "storage":
if ($row["db_id"]==-1
|| $g_settings["order_system"]=="fundp" // fundp wants all to see the exact location
|| $db_user == ROOT) {
$retval=joinifnotempty(
array($row["storage_name"],
ifnotempty(s("compartment_short")." ",$row["compartment"]) // Fach X
)
);
}
else {
// $retval=$row["show_db_beauty_name"]; // Uncomment this and comment out the rest of the block to return to default behavior
$retval=joinifnotempty(
array($row["storage_name"],
ifnotempty(s("compartment_short")." ",$row["compartment"]) // Fach X
)
);
}case "storage":
if ($row["db_id"]==-1
|| $g_settings["order_system"]=="fundp" // fundp wants all to see the exact location
|| $db_user == ROOT
|| $db_user == "special_person") { //this is to add some person to be able to the see the location
$retval=joinifnotempty(
array($row["storage_name"],
ifnotempty(s("compartment_short")." ",$row["compartment"]) // Fach X
)
);
}
else {
$retval=$row["show_db_beauty_name"];
}
break;mysql -u root -pshow databases;
use test;CREATE TEMPORARY TABLE temp_storage (storage text, barcode varbinary(20));LOAD DATA LOCAL INFILE '/path-to-file/test.csv'
INTO TABLE temp_storage
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\n'
IGNORE 1 LINES;UPDATE storage
INNER JOIN temp_storage on temp_storage.storage=storage.storage_name
SET storage.storage_barcode=temp_storage.barcode;DROP TEMPORARY TABLE temp_storage;use test;CREATE TEMPORARY TABLE temp_storage (storage text, barcode varbinary(20));
LOAD DATA INFILE '/var/lib/mysql/test.csv' INTO TABLE temp_storage
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\n'
IGNORE 1 LINES;
UPDATE storage
INNER JOIN temp_storage on temp_storage.storage=storage.storage_name
SET storage.storage_barcode=temp_storage.barcode;
DROP TEMPORARY TABLE temp_storage;ssh -p xxxx yy@ zz.zz.zz.zzyum –y install sudoyum –y install firewalld
systemctl start firewalld
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --permanent --zone=public --add-port=7822/tcp
firewall-cmd –reload
systemctl enable firewalldyum -y install php-mysql php-gd php-mbstring php-pear zlib-devel ghostscript ImageMagick libreoffice
systemctl restart httpdmkdir download
cd download
wget https://sourceforge.net/projects/enventory/files/open_enventory_2018-02-21.zip
unzip open_enventory_2018-02-21.zip
cp -rp open_enventory_2018-02-21/. /var/www/html/oevi /var/www/html/oe/.htaccesssystemctl restart httpdvi /etc/my.cnf.d/server.cnfsql_mode = NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
max_allowed_packet = 64M # (or higher)
innodb_buffer_pool_size = 1024M # to about 50% of the available memorysystemctl restart httpd mariadb/Applications/XAMPP/bin/mysql --user=root --password=gue55me -e "SELECT 1+1" /* Khoi: add customization identifier so that codes specific for your-school-name will be execute. Only change if you know what you are doing */
$default_g_settings["customization"]="your-school-name";SELECT * FROM chemical_storage WHERE borrowed_by_person_id=8UPDATE chemical_storage SET borrowed_by_person_id=NULL WHERE borrowed_by_person_id=8SELECT * FROM chemical_storage WHERE owner_person_id=7UPDATE chemical_storage SET owner_person_id=NULL WHERE owner_person_id=7SELECT person_id FROM person WHERE username='julia'SELECT storage_id FROM storage WHERE storage_name LIKE 'FH-2206%'SELECT * FROM chemical_storage
WHERE owner_person_id=15 AND storage_id NOT LIKE 18UPDATE chemical_storage
SET owner_person_id='NULL'
WHERE owner_person_id=15 AND storage_id NOT LIKE 18SELECT storage_name,storage_id
FROM storage
WHERE storage_id IN
(SELECT storage_id
FROM chemical_storage
WHERE owner_person_id in
(SELECT person_id FROM person WHERE username='mingzhao')
)
GROUP BY storage_nameUPDATE chemical_storage
SET owner_person_id=null
WHERE owner_person_id=13 AND storage_id IN (19,7,5,4,12,8)SELECT chemical_storage_barcode
FROM chemical_storage
WHERE chemical_storage_disabled IS NULL AND chemical_storage_barcode != ""
GROUP BY chemical_storage_barcode
HAVING Count(*) > 1;SELECT molecule_id,
chemical_storage_id,
chemical_storage_created_when,
chemical_storage_created_by,
chemical_storage_barcode
FROM chemical_storage
WHERE chemical_storage_barcode IN
(SELECT chemical_storage_barcode
FROM chemical_storage
WHERE chemical_storage_disabled IS NULL AND chemical_storage_barcode != ""
GROUP BY chemical_storage_barcode
HAVING Count(*) > 1
) AND
chemical_storage_created_by = "user1" AND
chemical_storage_created_when > '2019-08-16 18:00:00'
ORDER BY chemical_storage_barcode;mysql –u root -pshow databases;
use test;truncate table chemical_storage;
truncate table cache;
truncate table change_notify;alter table chemical_storage auto_increment=1exitsystemctl restart httpd mariadbSELECT chemical_storage_id, chemical_storage_barcode, count(chemical_storage_barcode) as NumOccurrences
from `chemical_storage`
WHERE chemical_storage_disabled is NULL
GROUP BY chemical_storage_barcode
HAVING (COUNT(chemical_storage_barcode) > 1)[mysqld]
sql_mode = NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
max_allowed_packet = 64M # (or higher)
innodb_buffer_pool_size = 1024M # to about 50% of the available memory
innodb_log_file_size = 128M # to about 10% of the available memorydate.timezone=Europe/Berlinif (in_array($g_settings["customization"], array("baylor", "mit", "your-school-name", ), true)) {docker pull khoivan88/centos7-lamp_for_oe





date.timezone=America/Chicagosudo vi /etc/httpd/conf.d/oe.confNameVirtualHost *:80
<VirtualHost *:80>
ServerName your_url.net
DocumentRoot /var/www/html/oe
Redirect permanent / https://your_url.net
</VirtualHost>
NameVirtualHost *:443
<VirtualHost *:443>
SSLEngine on
SSLCertificateFile /etc/pki/tls/certs/ca.crt
SSLCertificateKeyFile /etc/pki/tls/private/ca.key
<Directory /var/www/html/oe>
AllowOverride All
</Directory>
DocumentRoot /var/www/html/oe
ServerName your_url.net
</VirtualHost>sudo systemctl restart httpd.servicecrontab –e#This is to back up the Romo's OE database into home/khoi/OEbackup, every day at 00:05 am
5 0 * * * mysqldump -u root –pyour-password romo > /home/khoi/OEbackup/romo-backup-`date +"%Y%m%d"`.sql
#This is to back up the user table in mysql in order to save users' password, every day at 00:10 am
10 0 * * * mysqldump -u root -pyour-password mysql user > /home/khoi/OEbackup/romo-backup-user`date +"%Y%m%d"`.sql
#This is to copy the back up file to External harddrive, every day at 00:15 am
15 0 * * * sshpass -p your-password rsync -ave ssh --ignore-existing /home/khoi/OEbackup/ daniel@romomacpro.ddns.net:/Users/daniel/Documents/OEbackup/
#This is to delete the file every month
0 0 * * */4 rm -r /home/khoi/OEbackup/romo-backup-*.sqlcat /var/log/httpd/access_log | awk '{print $1}' | sort -n | uniq -c | sort -nr | head -20firewall-cmd --permanent --get-ipsetsfirewall-cmd --permanent --info-ipset=testfirewall-cmd --permanent --ipset=test --get-entriestar cvpzf /backups/backup-$(date +\%Y\%m\%d).tgz --exclude=/proc --exclude=/lost+found --exclude=/backups --exclude=/dev --exclude=/sys --exclude=/boot/grub --exclude=/etc/fstab --exclude=/etc/sysconfig/network-scripts/ --exclude=/etc/udev/rules.d/70-persistent-net.rules --exclude=/home/some_other_foldersvi /etc/httpd/conf/httpd.confsystemctl restart httpd<VirtualHost XX.XX.XX.XX:80>
DocumentRoot /var/www/html/site2.com
ServerName server.site2.com
ServerAlias site2.com www.site2.com
</VirtualHost><VirtualHost XX.XX.XX.XX:80>
DocumentRoot /var/www/html/site2.com
ServerName server.site2.com
ServerAlias site2.com www.site2.com
</VirtualHost>
<IfModule mod_ssl.c>
<VirtualHost XX.XX.XX.XX:443>
DocumentRoot /var/www/html/site2.com
ServerName server.site2.com
ServerAlias site2.com www.site2.com
SSLCertificateFile /etc/letsencrypt/live/site2.com/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/site2.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateChainFile /etc/letsencrypt/live/site2.com/chain.pem
</VirtualHost>
</IfModule>lib_customization.your-school-name.php$default_g_settings["order_system"]="fundp";




/* Khoi: add customization identifier so that codes specific for your-school-name will be execute. Only change if you know what you are doing */
$default_g_settings["customization"]="your-school-name";if (in_array($g_settings["customization"], array("baylor", "mit", "your-school-name", ), true)) {







































































































