Browse Source

FD3-386 Se importa el schema sql de freeradius

Guillermo Espinoza 7 years ago
parent
commit
53fb5bbb29
3 changed files with 277 additions and 0 deletions
  1. 263 0
      tools/mysql/freeradius/schema.sql
  2. 11 0
      tools/playbook.yml
  3. 3 0
      tools/src/Release.php

+ 263 - 0
tools/mysql/freeradius/schema.sql

@@ -0,0 +1,263 @@
+USE mysql;
+REPLACE INTO user (Host, User, Password) VALUES ('localhost','radius','radpass');
+REPLACE INTO db (Host, Db, User, Select_priv) VALUES ('localhost','radius','radius','Y');
+GRANT USAGE ON * . * TO 'radius'@'localhost' IDENTIFIED BY 'radpass';
+CREATE DATABASE IF NOT EXISTS radius;
+FLUSH PRIVILEGES;
+GRANT ALL PRIVILEGES ON radius . * TO 'radius'@'localhost';
+FLUSH PRIVILEGES;
+
+
+USE radius;
+CREATE TABLE IF NOT EXISTS `badusers` (
+  `id` int(10) NOT NULL AUTO_INCREMENT,
+  `UserName` varchar(30) DEFAULT NULL,
+  `Date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
+  `Reason` varchar(200) DEFAULT NULL,
+  `Admin` varchar(30) DEFAULT '-',
+  PRIMARY KEY (`id`),
+  KEY `UserName` (`UserName`),
+  KEY `Date` (`Date`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
+
+-- --------------------------------------------------------
+
+--
+-- Estructura de tabla para la tabla `mtotacct`
+--
+
+CREATE TABLE IF NOT EXISTS `mtotacct` (
+  `MTotAcctId` bigint(21) NOT NULL AUTO_INCREMENT,
+  `UserName` varchar(64) NOT NULL DEFAULT '',
+  `AcctDate` date NOT NULL DEFAULT '0000-00-00',
+  `ConnNum` bigint(12) DEFAULT NULL,
+  `ConnTotDuration` bigint(12) DEFAULT NULL,
+  `ConnMaxDuration` bigint(12) DEFAULT NULL,
+  `ConnMinDuration` bigint(12) DEFAULT NULL,
+  `InputOctets` bigint(12) DEFAULT NULL,
+  `OutputOctets` bigint(12) DEFAULT NULL,
+  `NASIPAddress` varchar(15) DEFAULT NULL,
+  PRIMARY KEY (`MTotAcctId`),
+  KEY `UserName` (`UserName`),
+  KEY `AcctDate` (`AcctDate`),
+  KEY `UserOnDate` (`UserName`,`AcctDate`),
+  KEY `NASIPAddress` (`NASIPAddress`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
+
+-- --------------------------------------------------------
+
+--
+-- Estructura de tabla para la tabla `nas`
+--
+
+CREATE TABLE IF NOT EXISTS `nas` (
+  `id` int(10) NOT NULL AUTO_INCREMENT,
+  `nasname` varchar(128) NOT NULL DEFAULT '',
+  `shortname` varchar(32) DEFAULT NULL,
+  `type` varchar(30) DEFAULT 'other',
+  `ports` int(5) DEFAULT NULL,
+  `secret` varchar(60) NOT NULL DEFAULT 'secret',
+  `community` varchar(50) DEFAULT NULL,
+  `description` varchar(200) DEFAULT 'RADIUS Client',
+  `server` varchar(32) NOT NULL,
+  `acct_enabled` tinyint(1) NOT NULL,
+  PRIMARY KEY (`id`),
+  KEY `nasname` (`nasname`)
+) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
+
+-- --------------------------------------------------------
+
+--
+-- Estructura de tabla para la tabla `radacct`
+--
+
+CREATE TABLE IF NOT EXISTS `radacct` (
+  `radacctid` bigint(21) NOT NULL AUTO_INCREMENT,
+  `acctsessionid` varchar(64) NOT NULL DEFAULT '',
+  `acctuniqueid` varchar(32) NOT NULL DEFAULT '',
+  `username` varchar(64) NOT NULL DEFAULT '',
+  `groupname` varchar(64) NOT NULL DEFAULT '',
+  `realm` varchar(64) DEFAULT '',
+  `nasipaddress` varchar(15) NOT NULL DEFAULT '',
+  `nasportid` varchar(15) DEFAULT NULL,
+  `nasporttype` varchar(32) DEFAULT NULL,
+  `acctstarttime` datetime DEFAULT NULL,
+  `acctstoptime` datetime DEFAULT NULL,
+  `acctsessiontime` int(12) DEFAULT NULL,
+  `acctauthentic` varchar(32) DEFAULT NULL,
+  `connectinfo_start` varchar(50) DEFAULT NULL,
+  `connectinfo_stop` varchar(50) DEFAULT NULL,
+  `acctinputoctets` bigint(20) DEFAULT NULL,
+  `acctoutputoctets` bigint(20) DEFAULT NULL,
+  `calledstationid` varchar(50) NOT NULL DEFAULT '',
+  `callingstationid` varchar(50) NOT NULL DEFAULT '',
+  `acctterminatecause` varchar(32) NOT NULL DEFAULT '',
+  `servicetype` varchar(32) DEFAULT NULL,
+  `framedprotocol` varchar(32) DEFAULT NULL,
+  `framedipaddress` varchar(15) NOT NULL DEFAULT '',
+  `acctstartdelay` int(12) DEFAULT NULL,
+  `acctstopdelay` int(12) DEFAULT NULL,
+  `xascendsessionsvrkey` varchar(10) DEFAULT NULL,
+  `updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+  PRIMARY KEY (`radacctid`),
+  KEY `username` (`username`),
+  KEY `framedipaddress` (`framedipaddress`),
+  KEY `acctsessionid` (`acctsessionid`),
+  KEY `acctsessiontime` (`acctsessiontime`),
+  KEY `acctuniqueid` (`acctuniqueid`),
+  KEY `acctstarttime` (`acctstarttime`),
+  KEY `acctstoptime` (`acctstoptime`),
+  KEY `nasipaddress` (`nasipaddress`)
+) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
+
+-- --------------------------------------------------------
+
+--
+-- Estructura de tabla para la tabla `radcheck`
+--
+
+CREATE TABLE IF NOT EXISTS `radcheck` (
+  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
+  `UserName` varbinary(64) NOT NULL DEFAULT '',
+  `Attribute` varchar(32) NOT NULL DEFAULT '',
+  `op` char(2) NOT NULL DEFAULT '==',
+  `Value` varchar(253) NOT NULL DEFAULT '',
+  PRIMARY KEY (`id`),
+  KEY `UserName` (`UserName`(32))
+) ENGINE=MyISAM  DEFAULT CHARSET=latin1 PACK_KEYS=0 AUTO_INCREMENT=1 ;
+
+-- --------------------------------------------------------
+
+--
+-- Estructura de tabla para la tabla `radgroupcheck`
+--
+
+CREATE TABLE IF NOT EXISTS `radgroupcheck` (
+  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
+  `GroupName` varchar(64) NOT NULL DEFAULT '',
+  `Attribute` varchar(32) NOT NULL DEFAULT '',
+  `op` char(2) NOT NULL DEFAULT '==',
+  `Value` varchar(253) NOT NULL DEFAULT '',
+  PRIMARY KEY (`id`),
+  KEY `GroupName` (`GroupName`(32))
+) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
+
+-- --------------------------------------------------------
+
+--
+-- Estructura de tabla para la tabla `radgroupreply`
+--
+
+CREATE TABLE IF NOT EXISTS `radgroupreply` (
+  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
+  `GroupName` varchar(64) NOT NULL DEFAULT '',
+  `Attribute` varchar(32) NOT NULL DEFAULT '',
+  `op` char(2) NOT NULL DEFAULT '=',
+  `Value` varchar(253) NOT NULL DEFAULT '',
+  `prio` int(10) unsigned NOT NULL DEFAULT '0',
+  PRIMARY KEY (`id`),
+  KEY `GroupName` (`GroupName`(32))
+) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
+
+-- --------------------------------------------------------
+
+--
+-- Estructura de tabla para la tabla `radpostauth`
+--
+
+CREATE TABLE IF NOT EXISTS `radpostauth` (
+  `id` int(11) NOT NULL AUTO_INCREMENT,
+  `username` varchar(64) NOT NULL DEFAULT '',
+  `pass` varchar(64) NOT NULL DEFAULT '',
+  `reply` varchar(32) NOT NULL DEFAULT '',
+  `authdate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+  PRIMARY KEY (`id`)
+) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
+
+-- --------------------------------------------------------
+
+--
+-- Estructura de tabla para la tabla `radreply`
+--
+
+CREATE TABLE IF NOT EXISTS `radreply` (
+  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
+  `UserName` varchar(64) NOT NULL DEFAULT '',
+  `Attribute` varchar(32) NOT NULL DEFAULT '',
+  `op` char(2) NOT NULL DEFAULT '=',
+  `Value` varchar(253) NOT NULL DEFAULT '',
+  PRIMARY KEY (`id`),
+  KEY `UserName` (`UserName`(32))
+) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
+
+-- --------------------------------------------------------
+
+--
+-- Estructura de tabla para la tabla `radusergroup`
+--
+
+CREATE TABLE IF NOT EXISTS `radusergroup` (
+  `username` varchar(64) NOT NULL DEFAULT '',
+  `groupname` varchar(64) NOT NULL DEFAULT '',
+  `priority` int(11) NOT NULL DEFAULT '1',
+  KEY `username` (`username`(32))
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+
+-- --------------------------------------------------------
+
+--
+-- Estructura de tabla para la tabla `totacct`
+--
+
+CREATE TABLE IF NOT EXISTS `totacct` (
+  `TotAcctId` bigint(21) NOT NULL AUTO_INCREMENT,
+  `UserName` varchar(64) NOT NULL DEFAULT '',
+  `AcctDate` date NOT NULL DEFAULT '0000-00-00',
+  `ConnNum` bigint(12) DEFAULT NULL,
+  `ConnTotDuration` bigint(12) DEFAULT NULL,
+  `ConnMaxDuration` bigint(12) DEFAULT NULL,
+  `ConnMinDuration` bigint(12) DEFAULT NULL,
+  `InputOctets` bigint(12) DEFAULT NULL,
+  `OutputOctets` bigint(12) DEFAULT NULL,
+  `NASIPAddress` varchar(15) DEFAULT NULL,
+  PRIMARY KEY (`TotAcctId`),
+  KEY `UserName` (`UserName`),
+  KEY `AcctDate` (`AcctDate`),
+  KEY `UserOnDate` (`UserName`,`AcctDate`),
+  KEY `NASIPAddress` (`NASIPAddress`),
+  KEY `NASIPAddressOnDate` (`AcctDate`,`NASIPAddress`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
+
+-- --------------------------------------------------------
+
+--
+-- Estructura de tabla para la tabla `usergroup`
+--
+
+CREATE TABLE IF NOT EXISTS `usergroup` (
+  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
+  `UserName` varchar(64) NOT NULL DEFAULT '',
+  `GroupName` varchar(64) NOT NULL DEFAULT '',
+  PRIMARY KEY (`id`),
+  KEY `UserName` (`UserName`(32))
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
+
+-- --------------------------------------------------------
+
+--
+-- Estructura de tabla para la tabla `userinfo`
+--
+
+CREATE TABLE IF NOT EXISTS `userinfo` (
+  `id` int(10) NOT NULL AUTO_INCREMENT,
+  `UserName` varchar(30) DEFAULT NULL,
+  `Name` varchar(200) DEFAULT NULL,
+  `Mail` varchar(200) DEFAULT NULL,
+  `Department` varchar(200) DEFAULT NULL,
+  `WorkPhone` varchar(200) DEFAULT NULL,
+  `HomePhone` varchar(200) DEFAULT NULL,
+  `Mobile` varchar(200) DEFAULT NULL,
+  PRIMARY KEY (`id`),
+  KEY `UserName` (`UserName`),
+  KEY `Departmet` (`Department`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

+ 11 - 0
tools/playbook.yml

@@ -109,6 +109,17 @@
         name: fd_session
         target: "/tmp/mysql_scripts.sql"
 
+    - copy:
+        src: "{{ playbook_dir }}/freeradius_schema.sql"
+        dest: /tmp/freeradius_schema.sql
+
+    - name: Create freeradius MySQL schema
+      mysql_db:
+        login_password: "{{ lookup('env', 'MYSQL_PASSWORD') }}"
+        state: import
+        name: freeradius
+        target: "/tmp/freeradius_schema.sql"
+
     - name: Create user iksop
       mysql_user:
         name: 'iksop'

+ 3 - 0
tools/src/Release.php

@@ -299,6 +299,9 @@ class Release extends Command
             copy(getcwd() . "/mysql_scripts.sql", $dObj->dirExists()->realpath()->getPath() . "/mysql_scripts.sql");
 
             copy(getcwd() . "/docker-compose.service", $dObj->dirExists()->realpath()->getPath() . "/docker-compose.service");
+
+            // copio script mysql schema freeradius
+            copy(getcwd() . "/mysql/freeradius/schema.sql", $dObj->dirExists()->realpath()->getPath() . "/freeradius_schema.sql");
         } catch (\Throwable $error) {
             var_dump($error->getTraceAsString(), $error->getCode(), $error->getMessage());
         } finally {