├── .gitignore ├── README.md ├── admin └── index.html ├── hooks ├── admin_txt.html └── user_txt.html ├── php ├── Config │ ├── local.example.php │ └── main.php ├── Controllers │ └── RedisController.php ├── Hooks │ └── DirectAdmin │ │ └── userDestroyPost.php ├── Templates │ └── redis-instance.conf ├── bootstrap.php └── php.ini ├── plugin.conf ├── screenshots └── list.png ├── scripts └── install.sh ├── setup ├── install.sh ├── redis.service ├── redis.sudoers └── redis@.service └── user ├── create.html ├── delete.html └── index.html /.gitignore: -------------------------------------------------------------------------------- 1 | .zip 2 | *.rar 3 | *.tar 4 | *.tar.gz 5 | *.tgz 6 | *.gzip 7 | *.gz 8 | .idea/* 9 | *.orig 10 | *.log 11 | *.bat 12 | *.DS_Store 13 | **/__MACOSX 14 | 15 | /analytics/* 16 | 17 | \.DS_* 18 | \._.DS_* 19 | Thumbs\.db 20 | test\* 21 | data\* 22 | logs\* 23 | 24 | php/Config/local.php -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DirectAdmin SSH Key Management Plugin 2 | Welcome to this repository of an unofficial DirectAdmin plugin for managing Redis instances. 3 | 4 | With this plugin end-users on an DirectAdmin server can easliy add and remove their redis instances. 5 | 6 | I developed and used this plugin for over a year now on our own servers, but I decided to release it to the public! So everyone can use this. 7 | 8 | # Installation 9 | ## Requirements 10 | This plugin works on every DirectAdmin server, but the included setup script is only for RHEL/CentOS with systemctl support. Maybe I will add install scripts for Ubuntu / Debian in the future. 11 | 12 | For enabeling, starting and stopping for redis instances it uses sudo with minimal permissions. 13 | ## Plugin installation 14 | ``` 15 | cd /usr/local/directadmin/plugins 16 | git clone https://github.com/kbentlage/da-redis-management.git redis_management 17 | sh redis_management/scripts/install.sh 18 | ``` 19 | 20 | ## Redis installation 21 | ``` 22 | cd /usr/local/directadmin/plugins/redis_management/setup 23 | sh install.sh 24 | ``` 25 | 26 | # Configuration 27 | By default, the plugin is working out-of-the box. But it can be needed to change serveral configuration settings. 28 | 29 | The default settings are stored in /usr/local/directadmin/plugins/redis_management/php/Config/main.php. 30 | 31 | If you need to change for example the location where the redis data is stored (default in /var/lib/redis), you can do this in "local.php". Please do not change this in the "main.php" config file, because this file can be overwritten when a new version of this plugin is installed. 32 | 33 | # Update 34 | ``` 35 | cd /usr/local/directadmin/plugins/redis_management 36 | git pull 37 | ``` 38 | 39 | # Screenshots 40 | List Redis instances 41 | 42 | ![List Redis instances](https://raw.githubusercontent.com/kbentlage/da-redis-management/master/screenshots/list.png) -------------------------------------------------------------------------------- /admin/index.html: -------------------------------------------------------------------------------- 1 | #!/usr/local/bin/php -c/usr/local/directadmin/plugins/redis_management/php/php.ini 2 | 3 | getInstances(); 9 | 10 | if($instanceData) 11 | { 12 | echo ' 13 | 14 | 15 | 16 | 17 | 18 | 19 | '; 20 | 21 | foreach($instanceData as $user => $instances) 22 | { 23 | foreach($instances as $instance) 24 | { 25 | echo ' 26 | 27 | 28 | 29 | 30 | '; 31 | } 32 | } 33 | 34 | echo '
UserHostPortCreated
'.$user.'127.0.0.1'.$instance['port'].''.date('d-m-Y H:i', $instance['created']).'
'; 35 | } 36 | else 37 | { 38 | echo '

No redis instances created yet.

'; 39 | } 40 | ?> 41 | -------------------------------------------------------------------------------- /hooks/admin_txt.html: -------------------------------------------------------------------------------- 1 | All User Redis Instances 2 | -------------------------------------------------------------------------------- /hooks/user_txt.html: -------------------------------------------------------------------------------- 1 | Redis Management -------------------------------------------------------------------------------- /php/Config/local.example.php: -------------------------------------------------------------------------------- 1 | [ 19 | 'user' => 'myRedisUser', 20 | 'group' => 'myRedisGroup', 21 | 'dataDir' => '/home/redis', 22 | ], 23 | ]; -------------------------------------------------------------------------------- /php/Config/main.php: -------------------------------------------------------------------------------- 1 | [ 11 | 'dataFile' => 'data/instances.json', 12 | 'startPort' => 7001, 13 | ], 14 | 'redis' => [ 15 | 'user' => 'redis', 16 | 'group' => 'redis', 17 | 'configDir' => '/etc/redis/instances', 18 | 'dataDir' => '/var/lib/redis', 19 | ], 20 | ]; -------------------------------------------------------------------------------- /php/Controllers/RedisController.php: -------------------------------------------------------------------------------- 1 | init(); 26 | } 27 | 28 | /** 29 | * Init 30 | * 31 | * @return void 32 | */ 33 | public function init() 34 | { 35 | $this->_basePath = dirname(dirname(__DIR__)); 36 | $this->_config = require_once($this->_basePath.'/php/Config/main.php'); 37 | 38 | if($this->_config) 39 | { 40 | // if local config exists, merge it with default config 41 | if(file_exists($this->_basePath.'/php/Config/local.php')) 42 | { 43 | $localConfig = require_once($this->_basePath.'/php/Config/local.php'); 44 | 45 | $this->_config = array_replace_recursive($this->_config, $localConfig); 46 | } 47 | 48 | $this->_nextInstancePort = $this->_config['plugin']['startPort']; 49 | 50 | if (file_exists($this->_basePath . '/' . $this->_config['plugin']['dataFile'])) 51 | { 52 | $jsonContent = file_get_contents($this->_basePath . '/' . $this->_config['plugin']['dataFile']); 53 | 54 | if (@json_decode($jsonContent)) 55 | { 56 | $json = json_decode($jsonContent, TRUE); 57 | 58 | if (isset($json['instances'])) 59 | { 60 | $this->_instances = $json['instances']; 61 | } 62 | 63 | if (isset($json['nextInstancePort'])) 64 | { 65 | $this->_nextInstancePort = $json['nextInstancePort']; 66 | } 67 | } 68 | } 69 | } 70 | else 71 | { 72 | throw new \Exception('No config data available!'); 73 | } 74 | } 75 | 76 | /** 77 | * Get Instances 78 | * 79 | * @param null $username 80 | * 81 | * @return array 82 | */ 83 | public function getInstances($username = NULL) 84 | { 85 | if ($username) 86 | { 87 | if (isset($this->_instances[$username])) 88 | { 89 | return $this->_instances[$username]; 90 | } 91 | else 92 | { 93 | return NULL; 94 | } 95 | } 96 | else 97 | { 98 | if($this->_instances) 99 | { 100 | return $this->_instances; 101 | } 102 | else 103 | { 104 | return NULL; 105 | } 106 | } 107 | } 108 | 109 | /** 110 | * Create Instance 111 | * 112 | * @param $username 113 | * 114 | * @return bool 115 | */ 116 | public function createInstance($username) 117 | { 118 | $password = $this->_generatePassword(); 119 | $port = $this->_nextInstancePort; 120 | 121 | // add instance 122 | if ($this->_addInstanceData($username, $port, $password)) 123 | { 124 | // create instance config 125 | if ($this->_createInstanceConfig($port, $password)) 126 | { 127 | // save data 128 | if ($this->_saveData()) 129 | { 130 | // create instance data dir 131 | if($this->_createInstanceDataDir($port)) 132 | { 133 | // enable and start service 134 | $this->_enableService($port); 135 | $this->_startService($port); 136 | 137 | return TRUE; 138 | } 139 | } 140 | } 141 | } 142 | 143 | return FALSE; 144 | } 145 | 146 | /** 147 | * Delete Instance 148 | * 149 | * @param $username 150 | * @param $port 151 | * 152 | * @return bool 153 | */ 154 | public function deleteInstance($username, $port) 155 | { 156 | $this->_disableService($port); 157 | $this->_stopService($port); 158 | 159 | if ($this->_deleteInstanceData($username, $port)) 160 | { 161 | if ($this->_deleteInstanceConfig($port)) 162 | { 163 | $this->_deleteInstanceDataDir($port); 164 | 165 | // save data 166 | if ($this->_saveData()) 167 | { 168 | return TRUE; 169 | } 170 | } 171 | } 172 | 173 | return FALSE; 174 | } 175 | 176 | /** 177 | * Delete All User Instances 178 | * 179 | * @param $username 180 | * @return bool 181 | */ 182 | public function deleteAllUserInstances($username) 183 | { 184 | if(isset($this->_instances[$username]) && !empty($this->_instances[$username])) 185 | { 186 | foreach($this->_instances[$username] as $port => $instance) 187 | { 188 | $this->deleteInstance($username, $port); 189 | } 190 | 191 | return TRUE; 192 | } 193 | } 194 | 195 | /** 196 | * Add Instance Data 197 | * 198 | * @param $username 199 | * @param $port 200 | * @param $password 201 | * 202 | * @return bool 203 | */ 204 | private function _addInstanceData($username, $port, $password) 205 | { 206 | $this->_instances[$username][$port] = array( 207 | 'username' => $username, 208 | 'port' => $port, 209 | 'password' => $password, 210 | 'created' => time(), 211 | ); 212 | 213 | $this->_nextInstancePort++; 214 | 215 | return TRUE; 216 | } 217 | 218 | /** 219 | * Delete Instance Data 220 | * 221 | * @param $username 222 | * @param $port 223 | * 224 | * @return bool 225 | */ 226 | private function _deleteInstanceData($username, $port) 227 | { 228 | if (isset($this->_instances[$username][$port])) 229 | { 230 | unset($this->_instances[$username][$port]); 231 | 232 | // if user has no instances anymore, remove entire user segment 233 | if(!$this->_instances[$username]) 234 | { 235 | unset($this->_instances[$username]); 236 | } 237 | 238 | return TRUE; 239 | } 240 | 241 | return FALSE; 242 | } 243 | 244 | /** 245 | * Save 246 | * 247 | * @return bool 248 | */ 249 | private function _saveData() 250 | { 251 | // prepare data 252 | $data = array( 253 | 'instances' => $this->_instances, 254 | 'nextInstancePort' => $this->_nextInstancePort 255 | ); 256 | 257 | // encode data to json 258 | $json = json_encode($data); 259 | 260 | // determine data dir path 261 | $pathInfo = pathinfo($this->_basePath . '/' . $this->_config['plugin']['dataFile']); 262 | 263 | // check if data direcory already exists 264 | if (!is_dir($pathInfo['dirname'])) 265 | { 266 | // create data directory 267 | mkdir($pathInfo['dirname'], 0755, TRUE); 268 | } 269 | 270 | // save json to file 271 | if (file_put_contents($this->_basePath . '/' . $this->_config['plugin']['dataFile'], $json)) 272 | { 273 | return TRUE; 274 | } 275 | 276 | return FALSE; 277 | } 278 | 279 | /** 280 | * Create Instance Config 281 | * 282 | * @param $port 283 | * @param $password 284 | * 285 | * @return bool 286 | */ 287 | private function _createInstanceConfig($port, $password) 288 | { 289 | // get redis template contents 290 | if ($templateContent = file_get_contents($this->_basePath . '/php/Templates/redis-instance.conf')) 291 | { 292 | // replace variables with actual values 293 | $replaceTokens = array( 294 | '{{ port }}', 295 | '{{ password }}', 296 | '{{ dataDir }}', 297 | ); 298 | $replaceValues = array( 299 | $port, 300 | $password, 301 | $this->_config['redis']['dataDir'], 302 | ); 303 | $configContent = str_replace($replaceTokens, $replaceValues, $templateContent); 304 | 305 | // check if redis instance config dir needs to be created 306 | if (!is_dir($this->_config['redis']['configDir'].'/')) 307 | { 308 | mkdir($this->_config['redis']['configDir'].'/', 0755); 309 | chown($this->_config['redis']['configDir'].'/', $this->_config['redis']['user']); 310 | chgrp($this->_config['redis']['configDir'].'/', $this->_config['redis']['user']); 311 | } 312 | 313 | // save config file 314 | if (file_put_contents($this->_config['redis']['configDir'] . '/' . $port . '.conf', $configContent)) 315 | { 316 | chmod($this->_config['redis']['configDir'] . '/' . $port . '.conf',0600); 317 | return TRUE; 318 | } 319 | } 320 | 321 | return FALSE; 322 | } 323 | 324 | /** 325 | * Delete Instance Config 326 | * 327 | * @param $port 328 | * 329 | * @return bool 330 | */ 331 | public function _deleteInstanceConfig($port) 332 | { 333 | if (file_exists($this->_config['redis']['configDir'] . '/' . $port . '.conf')) 334 | { 335 | unlink($this->_config['redis']['configDir'] . '/' . $port . '.conf'); 336 | 337 | return TRUE; 338 | } 339 | 340 | return FALSE; 341 | } 342 | 343 | /** 344 | * Create Instance Data Dir 345 | * 346 | * @param $port 347 | * 348 | * @return bool 349 | */ 350 | public function _createInstanceDataDir($port) 351 | { 352 | // check if redis data dir needs to be created 353 | if (!is_dir($this->_config['redis']['dataDir'].'/')) 354 | { 355 | mkdir($this->_config['redis']['dataDir'].'/', 0755); 356 | chown($this->_config['redis']['dataDir'].'/', $this->_config['redis']['user']); 357 | chgrp($this->_config['redis']['dataDir'].'/', $this->_config['redis']['user']); 358 | } 359 | 360 | if(mkdir($this->_config['redis']['dataDir'].'/'.$port.'/', 0755)) 361 | { 362 | chown($this->_config['redis']['dataDir'].'/'.$port.'/', $this->_config['redis']['user']); 363 | chgrp($this->_config['redis']['dataDir'].'/'.$port.'/', $this->_config['redis']['user']); 364 | 365 | return TRUE; 366 | } 367 | 368 | return FALSE; 369 | } 370 | 371 | /** 372 | * Delete Instance Data Dir 373 | * 374 | * @param $port 375 | * 376 | * @return bool 377 | */ 378 | public function _deleteInstanceDataDir($port) 379 | { 380 | if(is_dir($this->_config['redis']['dataDir'].'/'.$port)) 381 | { 382 | if($this->_exec('rm -rf '.$this->_config['redis']['dataDir'].'/'.$port.'/')) 383 | { 384 | return TRUE; 385 | } 386 | } 387 | 388 | return FALSE; 389 | } 390 | 391 | /** 392 | * Enable Service 393 | * 394 | * @param $port 395 | * 396 | * @return bool 397 | */ 398 | public function _enableService($port) 399 | { 400 | return $this->_exec('sudo systemctl enable redis@' . $port); 401 | } 402 | 403 | /** 404 | * Disable Service 405 | * 406 | * @param $port 407 | * 408 | * @return bool 409 | */ 410 | public function _disableService($port) 411 | { 412 | return $this->_exec('sudo systemctl disable redis@' . $port); 413 | } 414 | 415 | /** 416 | * Start Service 417 | * 418 | * @param $port 419 | * 420 | * @return bool 421 | */ 422 | public function _startService($port) 423 | { 424 | return $this->_exec('sudo systemctl start redis@' . $port); 425 | } 426 | 427 | /** 428 | * Stop Service 429 | * 430 | * @param $port 431 | * 432 | * @return bool 433 | */ 434 | public function _stopService($port) 435 | { 436 | return $this->_exec('sudo systemctl stop redis@' . $port); 437 | } 438 | 439 | /** 440 | * Exec 441 | * 442 | * @param $command 443 | * 444 | * @return bool 445 | */ 446 | public function _exec($command) 447 | { 448 | if ($output = shell_exec($command)) 449 | { 450 | return $output; 451 | } 452 | 453 | return FALSE; 454 | } 455 | 456 | /** 457 | * Generate Password 458 | * 459 | * @param int $length 460 | * @param bool $add_dashes 461 | * @param string $available_sets 462 | * 463 | * @return string 464 | */ 465 | private function _generatePassword($length = 15, $add_dashes = FALSE, $available_sets = 'luds') 466 | { 467 | $sets = array(); 468 | if (strpos($available_sets, 'l') !== FALSE) 469 | { 470 | $sets[] = 'abcdefghjkmnpqrstuvwxyz'; 471 | } 472 | if (strpos($available_sets, 'u') !== FALSE) 473 | { 474 | $sets[] = 'ABCDEFGHJKMNPQRSTUVWXYZ'; 475 | } 476 | if (strpos($available_sets, 'd') !== FALSE) 477 | { 478 | $sets[] = '23456789'; 479 | } 480 | if (strpos($available_sets, 's') !== FALSE) 481 | { 482 | $sets[] = '!@#$%&*?'; 483 | } 484 | $all = ''; 485 | $password = ''; 486 | foreach ($sets as $set) 487 | { 488 | $password .= $set[array_rand(str_split($set))]; 489 | $all .= $set; 490 | } 491 | $all = str_split($all); 492 | for ($i = 0; $i < $length - count($sets); $i++) 493 | { 494 | $password .= $all[array_rand($all)]; 495 | } 496 | $password = str_shuffle($password); 497 | if (!$add_dashes) 498 | { 499 | return $password; 500 | } 501 | $dash_len = floor(sqrt($length)); 502 | $dash_str = ''; 503 | while (strlen($password) > $dash_len) 504 | { 505 | $dash_str .= substr($password, 0, $dash_len) . '-'; 506 | $password = substr($password, $dash_len); 507 | } 508 | $dash_str .= $password; 509 | 510 | return $dash_str; 511 | } 512 | } -------------------------------------------------------------------------------- /php/Hooks/DirectAdmin/userDestroyPost.php: -------------------------------------------------------------------------------- 1 | #!/usr/local/bin/php -c/usr/local/directadmin/plugins/redis_management/php/php.ini 2 | deleteAllUserInstances($username)) 12 | { 13 | echo "User's redis instances removed."; 14 | } 15 | } 16 | ?> -------------------------------------------------------------------------------- /php/Templates/redis-instance.conf: -------------------------------------------------------------------------------- 1 | # include default config 2 | include /etc/redis.conf 3 | 4 | # instance config 5 | port {{ port }} 6 | requirepass {{ password }} 7 | dir {{ dataDir }}/{{ port }}/ 8 | pidfile /var/run/redis/{{ port }}.pid 9 | logfile /var/log/redis/{{ port }}.log -------------------------------------------------------------------------------- /php/bootstrap.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /php/php.ini: -------------------------------------------------------------------------------- 1 | short_open_tag = On 2 | log_errors = On 3 | error_log = /usr/local/directadmin/plugins/redis_management/logs/php-error.log 4 | date.timezone = Europe/Amsterdam -------------------------------------------------------------------------------- /plugin.conf: -------------------------------------------------------------------------------- 1 | name=Redis Management 2 | id=redis_management 3 | author=Kevin Bentlage 4 | version=1.1.2 5 | user_run_as=redis 6 | active=yes 7 | installed=yes 8 | -------------------------------------------------------------------------------- /screenshots/list.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kbentlage/da-redis-management/51028d72f4ae92e02524f4b0a06cf3d60be7cc82/screenshots/list.png -------------------------------------------------------------------------------- /scripts/install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Create log directory 4 | mkdir -p /usr/local/directadmin/plugins/redis_management/logs 5 | 6 | # Create data directory 7 | mkdir -p /usr/local/directadmin/plugins/redis_management/data 8 | 9 | # Fix ownerships 10 | chown -R diradmin.diradmin /usr/local/directadmin/plugins/redis_management 11 | chown -R redis.redis /usr/local/directadmin/plugins/redis_management/data 12 | 13 | # Fix permissions 14 | chmod -R 0775 /usr/local/directadmin/plugins/redis_management/admin/* 15 | chmod -R 0775 /usr/local/directadmin/plugins/redis_management/user/* 16 | 17 | # Inject user_destroy_post script 18 | if [ ! -f "/usr/local/directadmin/scripts/custom/user_destroy_post.sh" ]; then 19 | echo -e "#!/bin/bash" > /usr/local/directadmin/scripts/custom/user_destroy_post.sh 20 | chmod +x /usr/local/directadmin/scripts/custom/user_destroy_post.sh 21 | fi 22 | if [ ! "$(cat /usr/local/directadmin/scripts/custom/user_destroy_post.sh | grep redis_management)" ]; then 23 | echo -e '\n/usr/local/directadmin/plugins/redis_management/php/Hooks/DirectAdmin/userDestroyPost.php "$username"' >> /usr/local/directadmin/scripts/custom/user_destroy_post.sh 24 | fi 25 | 26 | # Make userDestroyPost.php script executable 27 | chmod +x /usr/local/directadmin/plugins/redis_management/php/Hooks/DirectAdmin/userDestroyPost.php -------------------------------------------------------------------------------- /setup/install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Install EPEL repository (if needed) 4 | if [ ! "$(rpm -qa | grep epel-release)" ]; then 5 | yum -y install epel-release 6 | fi 7 | 8 | # Install redis (if needed) 9 | if [ ! "$(rpm -qa | grep redis)" ]; then 10 | yum -y install redis 11 | fi 12 | 13 | # Determine PHP version 14 | PHP_VERSION=$(php -i | grep 'PHP Version'); 15 | 16 | # Remount /tmp with execute permissions (only if /tmp partition exists and is read-only) 17 | REMOUNT_TMP=false 18 | if [ "$(mount | grep /tmp | grep noexec)" ]; then 19 | mount -o remount,exec /tmp 20 | 21 | REMOUNT_TMP=true 22 | fi 23 | 24 | # Install php-redis module (if not installed yet) 25 | if [ ! "$(php -m | grep redis)" ]; then 26 | if [[ $PHP_VERSION == *"7."* ]]; then 27 | yes '' | pecl install -f redis 28 | else 29 | yes '' | pecl install -f redis-2.2.8 30 | fi 31 | fi 32 | 33 | # Enable redis php extension in custom php.ini (if not enabled yet) 34 | if [ ! "$(cat /usr/local/lib/php.conf.d/20-custom.ini | grep redis.so)" ]; then 35 | echo -e "\n; Redis\nextension=redis.so" >> /usr/local/lib/php.conf.d/20-custom.ini 36 | fi 37 | 38 | # Restart apache 39 | systemctl restart httpd 40 | 41 | # Remount /tmp with noexec permissions (if needed) 42 | if [ "$REMOUNT_TMP" = true ] ; then 43 | mount -o remount,noexec /tmp 44 | fi 45 | 46 | # Create instances folder for redis instances 47 | mkdir -p /etc/redis/instances 48 | 49 | # Chown instances folder 50 | chown -R redis.redis /etc/redis/instances 51 | 52 | # Remove existing systemctl script 53 | rm -f /lib/systemd/system/redis.service 54 | 55 | # Copy new systemctl scripts 56 | cp -a redis@.service /lib/systemd/system/ 57 | cp -a redis.service /lib/systemd/system/ 58 | 59 | # Reload systemctl daemons 60 | systemctl daemon-reload 61 | 62 | # Enable main service 63 | systemctl enable redis.service 64 | 65 | # Copy sudoers file 66 | cp -a redis.sudoers /etc/sudoers.d/redis 67 | 68 | # Fix sudoers file permissions 69 | chown root.root /etc/sudoers.d/redis -------------------------------------------------------------------------------- /setup/redis.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Start all redis instances 3 | 4 | [Service] 5 | Type=oneshot 6 | ExecStart=/bin/true 7 | RemainAfterExit=yes 8 | 9 | [Install] 10 | WantedBy=multi-user.target -------------------------------------------------------------------------------- /setup/redis.sudoers: -------------------------------------------------------------------------------- 1 | redis ALL=(ALL) NOPASSWD: /usr/bin/systemctl enable redis@*, /usr/bin/systemctl disable redis@*, /usr/bin/systemctl start redis@*, /usr/bin/systemctl stop redis@* 2 | Defaults:redis !requiretty 3 | -------------------------------------------------------------------------------- /setup/redis@.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Redis instance %i 3 | After=network.target 4 | Requires=redis.service 5 | Before=redis.service 6 | BindsTo=redis.service 7 | 8 | [Service] 9 | ExecStart=/usr/bin/redis-server /etc/redis/instances/%i.conf --daemonize no 10 | ExecStop=/usr/libexec/redis-shutdown redis@%i 11 | User=redis 12 | Group=redis 13 | RuntimeDirectory=redis 14 | RuntimeDirectoryMode=0755 15 | 16 | [Install] 17 | WantedBy=redis.service 18 | -------------------------------------------------------------------------------- /user/create.html: -------------------------------------------------------------------------------- 1 | #!/usr/local/bin/php -c/usr/local/directadmin/plugins/redis_management/php/php.ini 2 | 3 | createInstance($username)) 11 | { 12 | echo '

Redis instance is succesfully created. Back to list.

'; 13 | } 14 | else 15 | { 16 | echo '

Redis instance is not created, due to an unkown error. Back to list.

'; 17 | } 18 | ?> -------------------------------------------------------------------------------- /user/delete.html: -------------------------------------------------------------------------------- 1 | #!/usr/local/bin/php -c/usr/local/directadmin/plugins/redis_management/php/php.ini 2 | 3 | deleteInstance($username, $port)) 14 | { 15 | echo '

Redis instance is succesfully deleted. Back to list.

'; 16 | } 17 | else 18 | { 19 | echo '

Redis instance is not deleted, due to an unkown error. Back to list.

'; 20 | } 21 | } 22 | else 23 | { 24 | echo '

Invalid request. Back to list.

'; 25 | } 26 | ?> -------------------------------------------------------------------------------- /user/index.html: -------------------------------------------------------------------------------- 1 | #!/usr/local/bin/php -c/usr/local/directadmin/plugins/redis_management/php/php.ini 2 | 3 | getInstances($username); 11 | 12 | echo '

Create new redis instance.

'; 13 | 14 | if($instances) 15 | { 16 | echo ' 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | '; 25 | 26 | foreach($instances as $instance) 27 | { 28 | echo ' 29 | 30 | 31 | 32 | 33 | 34 | '; 35 | } 36 | 37 | echo '
HostPortPasswordCreatedDelete
127.0.0.1'.$instance['port'].''.$instance['password'].''.date('d-m-Y H:i', $instance['created']).'Delete
'; 38 | } 39 | else 40 | { 41 | echo '

No redis instances created yet. Create new redis instance.

'; 42 | } 43 | ?> --------------------------------------------------------------------------------