#!/bin/bash
#########################################################################################
# Criando banco de dados lt38c e tabela meuip:
#########################################################################################
/usr/bin/mysql -u root -pmysqllt38c -Bse "create database lt38c;"
/bin/echo 'SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for meuip
-- ----------------------------
DROP TABLE IF EXISTS `meuip`;
CREATE TABLE `meuip` (
`hostname` tinytext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`iplocal` tinytext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL,
`ipreal` tinytext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL,
`datah` datetime(6) NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP(6),
`ano` int(4) NULL DEFAULT NULL,
`semestre` tinyint(1) NULL DEFAULT NULL,
PRIMARY KEY (`hostname`(50)) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Compact;
SET FOREIGN_KEY_CHECKS = 1;' > /tmp/meuip.sql
/bin/cat /tmp/meuip.sql | mysql -u root -pmysqllt38c lt38c
#########################################################################################
# Fazendo download do script meuip.sh:
#########################################################################################
/usr/bin/wget www.lt38c.hturbo.com/meuip.sh -O /root/meuip.sh
/usr/bin/dos2unix /root/meuip.sh
/bin/chmod 100 /root/meuip.sh
# Configurar no arquivo meuip.sh; Usuário e Senha do Mysql(Local e Remoto), Ano e Semestre:
/usr/bin/mcedit /root/meuip.sh
# Compilar o script: /root/meuip.sh para /usr/bin/meuip:
/usr/local/bin/shc -f /root/meuip.sh -o /usr/bin/meuip
/bin/rm /root/*.x.c
/bin/rm /root/meuip.sh
# Executar o script /usr/bin/meuip 1x durante o boot:
/usr/bin/scp /etc/rc.local /etc/rc.local.bkp
/bin/sed -i '/fi/a /usr/bin/meuip 5 > /dev/null 2>&1' /etc/rc.local
#End