Net-FullAuto
view release on metacpan or search on metacpan
lib/Net/FullAuto/ISets/Local/Ampache_is.pm view on Meta::CPAN
package Net::FullAuto::ISets::Local::Ampache_is;
### OPEN SOURCE LICENSE - GNU AFFERO PUBLIC LICENSE Version 3.0 #######
#
# Net::FullAuto - Distributed Workload Automation Software
# Copyright © 2000-2026 Brian M. Kelly
#
# This program is free software: you can redistribute it and/or
# modify it under the terms of the GNU Affero General Public License
# as published by the Free Software Foundation, either version 3 of
# the License, or any later version.
#
# This program is distributed in the hope that it will be useful,
# but **WITHOUT ANY WARRANTY**; without even the implied warranty
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public
# License along with this program. If not, see:
# <http://www.gnu.org/licenses/agpl.html>.
#
#######################################################################
our $VERSION='0.01';
our $DISPLAY='AMPACHE';
our $CONNECT='secure';
our $defaultInstanceType='t2.micro';
my $service_and_cert_password='Full@ut0O1';
use 5.005;
use strict;
use warnings;
require Exporter;
our @ISA = qw(Exporter);
our @EXPORT = qw($select_ampache_setup);
use File::HomeDir;
use JSON::XS;
use POSIX qw(strftime);
my $home_dir=File::HomeDir->my_home.'/';
use Net::FullAuto::Cloud::fa_amazon;
use Net::FullAuto::FA_Core qw[$localhost];
# https://thechamberlands.net/video-streaming/
# https://github.com/jwplayer/jwplayer
my $configure_ampache=sub {
my $server_type=$_[0];
my $selection=$_[1]||'';
my $region=$_[2]||'';
my $verified_email=$_[3]||'';
my $permanent_ip=$_[4]||'';
my $site_name=$_[5]||'';
my $site_profile=$_[6]||'';
my $site_build=$_[7]||'';
$service_and_cert_password=$_[8]||'';
my $sudo='sudo ';
if ($site_profile=~/Commmunity/) {
$site_profile='community';
} elsif ($site_profile=~/Public/) {
$site_profile='public';
} elsif ($site_profile=~/Single/) {
$site_profile='singleuser';
} elsif ($site_profile=~/Private/) {
$site_profile='private';
}
$permanent_ip='' if $permanent_ip=~/Stay|Reason/;
if (exists $main::aws->{permanent_ip}) {
$permanent_ip=$main::aws->{permanent_ip};
}
my $test_aws='wget --timeout=5 --tries=1 -qO- '.
'http://169.254.169.254/latest/dynamic/instance-identity/';
$test_aws=`$test_aws`;
if (-1<index $test_aws,'signature') {
my $n=$main::aws->{fullauto}->
{SecurityGroups}->[0]->{GroupName}||'';
my $c='aws ec2 describe-security-groups '.
"--group-names $n";
my ($hash,$output,$error)=('','','');
($hash,$output,$error)=run_aws_cmd($c);
Net::FullAuto::FA_Core::handle_error($error) if $error;
my $cidr=$hash->{SecurityGroups}->[0]->{IpPermissions}
->[0]->{IpRanges}->[0]->{CidrIp};
$c='aws ec2 create-security-group --group-name '.
'AmpacheSecurityGroup --description '.
'"AMPACHE.com Security Group" 2>&1';
($hash,$output,$error)=run_aws_cmd($c);
Net::FullAuto::FA_Core::handle_error($error) if $error
&& $error!~/already exists/;
$c='aws ec2 authorize-security-group-ingress '.
'--group-name AmpacheSecurityGroup --protocol '.
'tcp --port 22 --cidr '.$cidr." 2>&1";
($hash,$output,$error)=run_aws_cmd($c);
Net::FullAuto::FA_Core::handle_error($error) if $error
&& $error!~/already exists/;
$c='aws ec2 authorize-security-group-ingress '.
'--group-name AmpacheSecurityGroup --protocol '.
'tcp --port 80 --cidr '.$cidr." 2>&1";
($hash,$output,$error)=run_aws_cmd($c);
Net::FullAuto::FA_Core::handle_error($error) if $error
&& $error!~/already exists/;
$c='aws ec2 authorize-security-group-ingress '.
'--group-name AmpacheSecurityGroup --protocol '.
lib/Net/FullAuto/ISets/Local/Ampache_is.pm view on Meta::CPAN
#'--with-libzip=/opt/source/libzip '.
'--with-zlib','__display__');
($stdout,$stderr)=$handle->cmd($sudo.'make -j2','__display__');
($stdout,$stderr)=$handle->cmd($sudo.'make install','__display__');
($stdout,$stderr)=$handle->cmd($sudo.
'mkdir -vp /usr/local/php7/etc/conf.d','__display__');
($stdout,$stderr)=$handle->cmd($sudo.
'cp -v ./php.ini-production /usr/local/php7/etc/php.ini',
'__display__');
($stdout,$stderr)=$handle->cmd($sudo.
'mkdir -vp /usr/local/php7/etc/conf.d','__display__');
($stdout,$stderr)=$handle->cmd($sudo.
'mkdir -vp /usr/local/php7/etc/php-fpm.d','__display__');
($stdout,$stderr)=$handle->cmd($sudo.
'cp -v ./sapi/fpm/www.conf /usr/local/php7/etc/php-fpm.d/www.conf',
'__display__');
($stdout,$stderr)=$handle->cmd($sudo.
'cp -v ./sapi/fpm/php-fpm.conf /usr/local/php7/etc/php-fpm.conf',
'__display__');
my $wcnf=<<END;
catch_workers_output = yes
php_flag[display_errors] = on
php_admin_value[error_log] = /usr/local/php7/var/log/fpm-php.www.log
php_admin_flag[log_errors] = on
END
($stdout,$stderr)=$handle->cmd(
"echo -e \"$wcnf\" | ${sudo}tee -a ".
'/usr/local/php7/etc/php-fpm.d/www.conf',
'__display__');
($stdout,$stderr)=$handle->cmd($sudo.
'touch /var/log/fpm-php.www.log');
($stdout,$stderr)=$handle->cmd($sudo.
'chmod -v 777 /var/log/fpm-php.www.log','__display__');
($stdout,$stderr)=$handle->cmd($sudo.
'cp -v ./sapi/fpm/php-fpm.conf /usr/local/php7/etc/php-fpm.conf',
'__display__');
my $zend=<<END;
; Zend OPcache
extension=opcache.so
END
($stdout,$stderr)=$handle->cmd("echo -e \"$zend\" > ".
'/usr/local/php7/etc/conf.d/modules.ini');
($stdout,$stderr)=$handle->cmd($sudo.
"sed -i 's/user = nobody/user = www-data/' ".
'/usr/local/php7/etc/php-fpm.d/www.conf');
($stdout,$stderr)=$handle->cmd($sudo.
"sed -i 's/group = nobody/group = www-data/' ".
'/usr/local/php7/etc/php-fpm.d/www.conf');
($stdout,$stderr)=$handle->cmd($sudo.
"sed -i 's/\;clear_env/clear_env/' ".
'/usr/local/php7/etc/php-fpm.d/www.conf');
($stdout,$stderr)=$handle->cmd($sudo.
"sed -i 's/\;env.PATH./env[PATH]/' ".
'/usr/local/php7/etc/php-fpm.d/www.conf');
($stdout,$stderr)=$handle->cmd($sudo.
'ln -s /usr/local/php7/sbin/php-fpm /usr/sbin/php-fpm');
($stdout,$stderr)=$handle->cmd($sudo.
'ln -s /usr/local/php7/bin/php /usr/bin/php');
#
# echo-ing/streaming files over ssh can be tricky. Use echo -e
# and replace these characters with thier HEX
# equivalents (use an external editor for quick
# search and replace - and paste back results.
# use copy/paste or cat file and copy/paste results.):
#
# ! - \\x21 ` - \\x60
# " - \\x22 \ - \\x5C
# $ - \\x24 % - \\x25
#
my $fpmsrv=<<END;
[Unit]
Description=The PHP FastCGI Process Manager
After=syslog.target network.target
[Service]
Type=simple
PIDFile=/run/php-fpm/php-fpm.pid
ExecStart=/usr/local/php7/sbin/php-fpm --nodaemonize --fpm-config /usr/local/php7/etc/php-fpm.conf
ExecReload=/bin/kill -USR2 \\x24MAINPID
[Install]
WantedBy=multi-user.target
END
($stdout,$stderr)=$handle->cwd("~");
($stdout,$stderr)=$handle->cmd("echo -e \"$fpmsrv\" > ".
'php-fpm.service');
($stdout,$stderr)=$handle->cmd($sudo.'mv -fv php-fpm.service '.
'/usr/lib/systemd/system');
($stdout,$stderr)=$handle->cwd("/opt/source");
($stdout,$stderr)=$handle->cmd($sudo.'mkdir -vp /run/php-fpm',
'__display__');
($stdout,$stderr)=$handle->cmd($sudo.
'chkconfig --levels 235 php-fpm on');
($stdout,$stderr)=$handle->cmd($sudo.'service php-fpm start',
'__display__');
($stdout,$stderr)=$handle->cmd($sudo.
'/usr/local/php7/bin/pecl channel-update pecl.php.net',
'__display__');
($stdout,$stderr)=$handle->cmd($sudo.
'/usr/local/php7/bin/pecl install mailparse-3.0.2',
'__display__');
}
($stdout,$stderr)=$handle->cmd($sudo.
'wget --random-wait --progress=dot '.
'https://dl.fedoraproject.org/pub/epel/'.
'epel-release-latest-7.noarch.rpm','__display__');
($stdout,$stderr)=$handle->cmd($sudo.
'yum install -y epel-release-latest-7.noarch.rpm',
'__display__');
($stdout,$stderr)=$handle->cmd($sudo.
'rm -rf epel-release-latest-7.noarch.rpm','__display__');
#($stdout,$stderr)=$handle->cmd($sudo.
# 'yum -y install epel-release',
# '__display__');
($stdout,$stderr)=$handle->cwd('/etc/yum.repos.d');
($stdout,$stderr)=$handle->cmd($sudo.
'wget --random-wait --progress=dot '.
'https://www.nasm.us/nasm.repo','__display__');
($stdout,$stderr)=$handle->cmd($sudo.
'yum -y --disablerepo=amzn2-core '.
lib/Net/FullAuto/ISets/Local/Ampache_is.pm view on Meta::CPAN
; Enable imagick extension module
extension=${img_ext}imagick.so
END
($stdout,$stderr)=$handle->cmd(
"echo -e \"$im\" > imagick.ini");
# use php -i | grep ini to check location of ini files
($stdout,$stderr)=$handle->cmd($sudo.
'mv -fv imagick.ini /usr/local/php7/etc/conf.d','__display__');
($stdout,$stderr)=$handle->cmd($sudo.
'mkdir -vp phpshield','__display__');
($stdout,$stderr)=$handle->cwd('phpshield');
# https://linuxflow.blogspot.com/2017/05/ampache-installation.html
($stdout,$stderr)=$handle->cmd($sudo.
'wget --random-wait --progress=dot '.
'https://www.sourceguardian.com/loaders/download/'.
'loaders.linux-x86_64.zip',300,'__display__');
($stdout,$stderr)=$handle->cmd($sudo.
'unzip loaders.linux-x86_64.zip','__display__');
($stdout,$stderr)=$handle->cmd($sudo.
"cp -v ixed.7.0.lin $img_ext",'__display__');
($stdout,$stderr)=$handle->cwd('/opt/source');
# https://forum.likg.org.ua/server-side-actions/
# install-phpshield-sourceguardian-php-encoders-t306.html
my $zd=<<END;
; Enable phpshield extension module
extension=${img_ext}ixed.7.0.lin
END
($stdout,$stderr)=$handle->cmd(
"echo -e \"$zd\" > phpshield.ini");
($stdout,$stderr)=$handle->cmd($sudo.
"mv -fv phpshield.ini /usr/local/php7/etc/conf.d",'__display__');
}
($stdout,$stderr)=$handle->cwd('/opt/source');
($stdout,$stderr)=$handle->cmd($sudo.'which mysql');
my $msstatus='';my $msversion='';
if ($stdout=~/\/mysql/) {
($msversion,$stderr)=$handle->cmd($sudo.
'mysql --version','__display__');
$msversion=~s/^mysql\s+Ver\s+(.*?)\s+Distrib.*$/$1/;
($msstatus,$stderr)=$handle->cmd($sudo.
'sudo service mysql status','__display__');
}
if ($msversion<15.1 || $msstatus!~/SUCCESS/) {
#my $u=1;
#if ($u==1) {
# https://docs.couchbase.com/server/6.0/install/thp-disable.html
my $do_thp=1;
($stdout,$stderr)=$handle->cmd($sudo.
'cat /sys/kernel/mm/transparent_hugepage/enabled');
if ($stdout!~/never/) {
($stdout,$stderr)=$handle->cmd($sudo.
'cat /sys/kernel/mm/redhat_transparent_hugepage/enabled');
if ($stdout!~/never/ || $stdout=~/\[never\]/) {
$do_thp=0;
}
} elsif ($stdout=~/\[never\]/) {
$do_thp=0;
}
if ($do_thp==1) {
#
# echo-ing/streaming files over ssh can be tricky. Use echo -e
# and replace these characters with thier HEX
# equivalents (use an external editor for quick
# search and replace - and paste back results.
# use copy/paste or cat file and copy/paste results.):
#
# ! - \\x21 ` - \\x60 * - \\x2A
# " - \\x22 \ - \\x5C
# $ - \\x24 % - \\x25
#
# https://www.lisenet.com/2014/ - bash approach to conversion
my $thp=<<END;
#\\x21/bin/bash
### BEGIN INIT INFO
# Provides: disable-thp
# Required-Start: \\x24local_fs
# Required-Stop:
# X-Start-Before: mysql
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Disable THP
# Description: disables Transparent Huge Pages (THP) on boot
### END INIT INFO
case \\x241 in
start)
if [ -d /sys/kernel/mm/transparent_hugepage ]; then
echo 'never' > /sys/kernel/mm/transparent_hugepage/enabled
echo 'never' > /sys/kernel/mm/transparent_hugepage/defrag
elif [ -d /sys/kernel/mm/redhat_transparent_hugepage ]; then
echo 'never' > /sys/kernel/mm/redhat_transparent_hugepage/enabled
echo 'never' > /sys/kernel/mm/redhat_transparent_hugepage/defrag
else
return 0
fi
;;
esac
END
($stdout,$stderr)=$handle->cmd($sudo.
"echo -e \"$thp\" > disable-thp");
($stdout,$stderr)=$handle->cmd($sudo.
'mv -fv disable-thp /etc/init.d/disable-thp',
'__display__');
($stdout,$stderr)=$handle->cmd($sudo.
'chmod -v 755 /etc/init.d/disable-thp',
'__display__');
($stdout,$stderr)=$handle->cmd($sudo.
'service disable-thp start','__display__');
($stdout,$stderr)=$handle->cmd($sudo.
'sudo chkconfig disable-thp on','__display__');
}
($stdout,$stderr)=$handle->cmd($sudo.
'systemctl stop mysql','__display__');
($stdout,$stderr)=$handle->cmd($sudo.
'systemctl stop mariadb','__display__');
($stdout,$stderr)=$handle->cmd($sudo.
'yum list installed | grep "[Mm]aria\|[Mm][Yy][Ss][Qq][Ll]"',
'__display__');
my @pkgs=split "\n", $stdout;
foreach my $pkg (@pkgs) {
$pkg=~s/^(.*?)\s+.*$/$1/;
lib/Net/FullAuto/ISets/Local/Ampache_is.pm view on Meta::CPAN
($stdout,$stderr)=$handle->cmd("sudo wget -qO- http://zlib.net/index.html");
my $zlib_ver=$stdout;
my $sha__256=$stdout;
$zlib_ver=~s/^.*? source code, version (\d+\.\d+\.\d+).*$/$1/s;
$sha__256=~s/^.*?SHA-256 hash [<]tt[>](.*?)[<][\/]tt[>].*$/$1/s;
foreach my $count (1..3) {
($stdout,$stderr)=$handle->cmd("sudo wget --random-wait --progress=dot ".
"http://zlib.net/zlib-$zlib_ver.tar.gz",'__display__');
$checksum=$sha__256;
($stdout,$stderr)=$handle->cmd(
"sudo sha256sum -c - <<<\"$checksum zlib-$zlib_ver.tar.gz\"",
'__display__');
unless ($stderr) {
print(qq{ + CHECKSUM Test for zlib-$zlib_ver *PASSED* \n});
last
} elsif ($count>=3) {
print "FATAL ERROR! : CHECKSUM Test for ".
"zlib-$zlib_ver.tar.gz *FAILED* ",
"after $count attempts\n";
&Net::FullAuto::FA_Core::cleanup;
}
($stdout,$stderr)=$handle->cmd("sudo rm -rvf zlib-$zlib_ver.tar.gz",
'__display__');
}
($stdout,$stderr)=$handle->cmd("sudo tar xvf zlib-$zlib_ver.tar.gz",
'__display__');
my $ossl='openssl-1.0.2h';
foreach my $count (1..3) {
$checksum='577585f5f5d299c44dd3c993d3c0ac7a219e4949';
($stdout,$stderr)=$handle->cmd("sudo wget --random-wait --progress=dot ".
"https://www.openssl.org/source/$ossl.tar.gz",
'__display__');
($stdout,$stderr)=$handle->cmd(
"sudo sha1sum -c - <<<\"$checksum $ossl.tar.gz\"",'__display__');
unless ($stderr) {
print(qq{ + CHECKSUM Test for $ossl *PASSED* \n});
last
} elsif ($count>=3) {
print "FATAL ERROR! : CHECKSUM Test for $ossl.tar.gz *FAILED* ",
"after $count attempts\n";
&Net::FullAuto::FA_Core::cleanup;
}
($stdout,$stderr)=$handle->cmd("sudo rm -rvf $ossl.tar.gz",'__display__');
}
($stdout,$stderr)=$handle->cmd("sudo tar xvf $ossl.tar.gz",'__display__');
($stdout,$stderr)=$handle->cwd("../..");
my $make_nginx=$sudo.'./configure --sbin-path=/usr/local/nginx/nginx '.
'--conf-path=/usr/local/nginx/nginx.conf '.
'--pid-path=/usr/local/nginx/nginx.pid '.
"--with-http_ssl_module --with-pcre=objs/lib/$pcre ".
"--with-zlib=objs/lib/zlib-$zlib_ver";
($stdout,$stderr)=$handle->cmd($make_nginx,'__display__');
($stdout,$stderr)=$handle->cmd(
"${sudo}sed -i 's/-Werror //' ./objs/Makefile");
($stdout,$stderr)=$handle->cmd("${sudo}make install",'__display__');
# https://www.liberiangeek.net/2015/10/
# how-to-install-self-signed-certificates-on-nginx-webserver/
#
# echo-ing/streaming files over ssh can be tricky. Use echo -e
# and replace these characters with thier HEX
# equivalents (use an external editor for quick
# search and replace - and paste back results.
# use copy/paste or cat file and copy/paste results.):
#
# ! - \\x21 ` - \\x60 * - \\x2A
# " - \\x22 \ - \\x5C
# $ - \\x24 % - \\x25
#
# https://www.lisenet.com/2014/ - bash approach to conversion
my $nginx_conf=<<END;
user www-data;
worker_processes auto;
pid /var/run/nginx.pid;
include /etc/nginx/modules-enabled/\\x2A.conf;
events {
worker_connections 1024;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /usr/local/nginx/mime.types;
default_type application/octet-stream;
##
# SSL Settings
##
#ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
#ssl_prefer_server_ciphers on;
##
# Logging Settings
##
#access_log /var/log/nginx/access.log;
#error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
lib/Net/FullAuto/ISets/Local/Ampache_is.pm view on Meta::CPAN
deny all;
}
}
location ^~ /bin/ {
deny all;
return 403;
}
location ^~ /config/ {
deny all;
return 403;
}
location / {
limit_except GET POST HEAD{
deny all;
}
}
location ~ ^/.\\x2A.php {
fastcgi_index index.php;
# sets the timeout for requests in [s] , 60s are normally enough
fastcgi_read_timeout 600s;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME \\x24document_root\\x24fastcgi_script_name;
# Mitigate HTTPOXY https://httpoxy.org/
fastcgi_param HTTP_PROXY \\x22\\x22;
# has to be set to on if encryption (https) is used:
# fastcgi_param HTTPS on;
fastcgi_split_path_info ^(.+?\\x5C.php)(/.\\x2A)\\x24;
# chose as your php-fpm is configured to listen on
fastcgi_pass unix:/var/run/php-fpm/php7.0-fpm.sock;
# fastcgi_pass 127.0.0.1:8000/;
}
# Rewrite rule for WebSocket
location /ws {
rewrite ^/ws/(.\\x2A) /\\x241 break;
proxy_http_version 1.1;
proxy_set_header Upgrade \\x24http_upgrade;
proxy_set_header Connection \\x22upgrade\\x22;
proxy_set_header Host \\x24host;
proxy_pass http://127.0.0.1:8100/;
}
}
}
END
($stdout,$stderr)=$handle->cmd(
"echo -e \"$nginx_conf\" > /usr/local/nginx/nginx.conf");
#
# echo-ing/streaming files over ssh can be tricky. Use echo -e
# and replace these characters with thier HEX
# equivalents (use an external editor for quick
# search and replace - and paste back results.
# use copy/paste or cat file and copy/paste results.):
#
# ! - \\x21 ` - \\x60 * - \\x2A
# " - \\x22 \ - \\x5C
# $ - \\x24 % - \\x25
#
# https://www.lisenet.com/2014/ - bash approach to conversion
my $nginx_start_stop=<<END;
#\\x21/bin/sh
#
# nginx - this script starts and stops the nginx daemin
#
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse # proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /usr/local/nginx/nginx.conf
# pidfile: /var/run/nginx.pid
# user: www-data
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ \\x22\\x24NETWORKING\\x22 = \\x22no\\x22 ] && exit 0
nginx=\\x22/usr/local/nginx/nginx\\x22
prog=\\x24(basename \\x24nginx)
NGINX_CONF_FILE=\\x22/usr/local/nginx/nginx.conf\\x22
lockfile=/usr/local/nginx/nginx.lock
start() {
[ -x \\x24nginx ] || exit 5
[ -f \\x24NGINX_CONF_FILE ] || exit 6
echo -n \\x24\\x22Starting \\x24prog: \\x22
daemon \\x24nginx -c \\x24NGINX_CONF_FILE
retval=\\x24?
echo
[ \\x24retval -eq 0 ] && touch \\x24lockfile
return \\x24retval
}
stop() {
echo -n \\x24\\x22Stopping \\x24prog: \\x22
killproc \\x24prog -QUIT
retval=\\x24?
echo
[ \\x24retval -eq 0 ] && rm -f \\x24lockfile
return \\x24retval
}
restart() {
configtest || return \\x24?
lib/Net/FullAuto/ISets/Local/Ampache_is.pm view on Meta::CPAN
my $first_pass=0;
my $second_pass=0;
my $third_pass=0;
my $fourth_pass=0;
my $fifth_pass=0;
while (1) {
my $output=Net::FullAuto::FA_Core::fetch($handle);
last if $output=~/$prompt/ && $first_pass;
print $output;
if (-1<index $output,'[(none)]>') {
if (!$first_pass) {
$handle->{_cmd_handle}->print(
"ALTER USER \'root\'@\'localhost\' ".
"IDENTIFIED BY \'$service_and_cert_password\';");
$first_pass=1;
} elsif (!$second_pass) {
$handle->{_cmd_handle}->print('CREATE DATABASE ampache;');
$second_pass=1;
} elsif (!$third_pass) {
$handle->{_cmd_handle}->print(
'GRANT USAGE ON ampache.* TO ampache@localhost'.
" IDENTIFIED BY \'$service_and_cert_password\';");
$third_pass=1;
} elsif (!$fourth_pass) {
$handle->{_cmd_handle}->print(
'GRANT ALL PRIVILEGES ON ampache.* TO ampache@localhost;');
$fourth_pass=1;
} elsif (!$fifth_pass) {
$handle->{_cmd_handle}->print('flush privileges;');
$fifth_pass=1;
} else {
$handle->{_cmd_handle}->print('exit;');
}
}
}
($stdout,$stderr)=$handle->cmd(
"${sudo}sed -i \'s#127.0.0.1:9000#/var/run/php-fpm/php7.0-fpm.sock#\' ".
'/usr/local/php7/etc/php-fpm.d/www.conf');
# https://serversforhackers.com/c/php-fpm-configuration-the-listen-directive
($stdout,$stderr)=$handle->cmd(
"${sudo}sed -i \'s/;listen.owner = nobody/listen.owner = www-data/\' ".
'/usr/local/php7/etc/php-fpm.d/www.conf');
($stdout,$stderr)=$handle->cmd(
"${sudo}sed -i \'s/user = apache/user = www-data/\' ".
'/usr/local/php7/etc/php-fpm.d/www.conf');
($stdout,$stderr)=$handle->cmd(
"${sudo}sed -i \'s/group = apache/group = www-data/\' ".
'/usr/local/php7/etc/php-fpm.d/www.conf');
($stdout,$stderr)=$handle->cmd(
"${sudo}sed -i \'s/;listen.mode = 0660/listen.mode = 0664/\' ".
'/usr/local/php7/etc/php-fpm.d/www.conf');
($stdout,$stderr)=$handle->cmd(
"${sudo}chgrp -Rv www-data /usr/local/php7/include/php/ext/session",
'__display__');
# '/var/lib/php/5.5/wsdlcache','__display__');
($stdout,$stderr)=$handle->cwd("/var/www/html/ampache");
($stdout,$stderr)=$handle->cmd("${sudo}chgrp -v www-data .");
($stdout,$stderr)=$handle->cmd("${sudo}chmod -v g+w .");
($stdout,$stderr)=$handle->cwd("/opt/source");
#
# echo-ing/streaming files over ssh can be tricky. Use echo -e
# and replace these characters with thier HEX
# equivalents (use an external editor for quick
# search and replace - and paste back results.
# use copy/paste or cat file and copy/paste results.):
#
# ! - \\x21 ` - \\x60 * - \\x2A
# " - \\x22 \ - \\x5C
# $ - \\x24 % - \\x25
#
# https://www.lisenet.com/2014/ - bash approach to conversion
my ($hash,$output,$error)=('','','');
$c="aws iam list-access-keys --user-name ampache_email";
($hash,$output,$error)=run_aws_cmd($c);
$hash||={};
foreach my $hash (@{$hash->{AccessKeyMetadata}}) {
my $c="aws iam delete-access-key --access-key-id $hash->{AccessKeyId} ".
"--user-name ampache_email";
($hash,$output,$error)=run_aws_cmd($c);
}
sleep 1;
$c="aws iam delete-user --user-name ampache_email";
($hash,$output,$error)=run_aws_cmd($c);
$c="aws iam create-user --user-name ampache_email";
($hash,$output,$error)=run_aws_cmd($c);
$c="aws iam create-access-key --user-name ampache_email";
($hash,$output,$error)=run_aws_cmd($c);
$hash||={};
my $access_id=$hash->{AccessKey}->{AccessKeyId};
my $secret_access_key=$hash->{AccessKey}->{SecretAccessKey};
my $java_smtp_generator=<<END;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import javax.xml.bind.DatatypeConverter;
public class SesSmtpCredentialGenerator {
// From http://docs.aws.amazon.com/ses/latest/DeveloperGuide/smtp-credentials.html
private static final String KEY_ENV_VARIABLE = \\x22AWS_SECRET_ACCESS_KEY\\x22; // Put your AWS secret access key in this environment variable.
private static final String MESSAGE = \\x22SendRawEmail\\x22; // Used to generate the HMAC signature. Do not modify.
private static final byte VERSION = 0x02; // Version number. Do not modify.
public static void main(String[] args) {
// Get the AWS secret access key from environment variable AWS_SECRET_ACCESS_KEY.
String key = System.getenv(KEY_ENV_VARIABLE);
if (key == null)
{
System.out.println(\\x22Error: Cannot find environment variable AWS_SECRET_ACCESS_KEY.\\x22);
System.exit(0);
}
// Create an HMAC-SHA256 key from the raw bytes of the AWS secret access key.
SecretKeySpec secretKey = new SecretKeySpec(key.getBytes(), \\x22HmacSHA256\\x22);
try {
// Get an HMAC-SHA256 Mac instance and initialize it with the AWS secret access key.
Mac mac = Mac.getInstance(\\x22HmacSHA256\\x22);
mac.init(secretKey);
lib/Net/FullAuto/ISets/Local/Ampache_is.pm view on Meta::CPAN
};
return $email_message;
};
our $ampache_enter_domain_name=sub {
my $ampache_domain_banner=<<'END';
___ _ ___ _ _ _
| __|_ _| |_ ___ _ _ | \ ___ _ __ __ _(_)_ _ | \| |__ _ _ __ ___
| _|| ' \ _/ -_) '_| | |) / _ \ ' \/ _` | | ' \ | .` / _` | ' \/ -_)
|___|_||_\__\___|_| |___/\___/_|_|_\__,_|_|_||_| |_|\_\__,_|_|_|_\___|
The Domain Name is the friendly address of your site - like fullauto.com
This setup will test the validity of your domain name, and coach you
through the steps you need to take to activate it successfully.
END
$ampache_domain_banner.=<<END;
Input box with === border is highlighted (active) input box.
Use [TAB] key to switch focus between input boxes.
Use [DEL] key to clear entire entry in highlighted input box.
Use [Backspace] to backspace in highlighted input box.
Type or Copy & Paste the Domain Name for AMPACHE here:
Domain Name
]I[{1,'',50}
END
my $ampache_enter_domain_name={
Name => 'ampache_enter_domain_name',
Input => 1,
Result => $ampache_validate_domain,
#Result => $ampache_setup_summary,
Banner => $ampache_domain_banner,
};
return $ampache_enter_domain_name;
};
our $ampache_caution=sub {
my $inform_banner=<<'END';
___ _ _ _ _____ ___ ___ _ _ _
/ __| /_\| | | |_ _|_ _/ _ \| \| | |
| (__ / _ \ |_| | | | | | (_) | .` |_|
\___/_/ \_\___/ |_| |___\___/|_|\_(_)
END
$inform_banner.=<<END;
This setup is intended to be a demonstration both of FullAutoâs automation
capabilities, as well as AMPACHEâs video streaming capabilities. For
this purpose, Amazon was chosen because of the fast ZERO to full AMPACHE
setup in one sitting. With other Cloud and host environments, there can be
significant delays, and it is not as easy to setup an account, have it
fully accessible, run the automation to completion, play with AMPACHE
and destroy it all easily after the evaluation is complete with minimal
if any charges. With Amazon you can do this very easily. You even get an
entire Gigabyte of free outbound bandwidth. Beyond uploading and evaluating
one or two modest videos on AMPACHE, you would **NOT** want to stream a
lot of video from Amazon â the bandwidth costs are simply too prohibitive
for anything beyond evaluation and demonstration. **PLEASE DONATE**
http://FullAuto.com/donate.html and help us to build a full featured
self-service dashboard that will work just as easily for other more
affordable hosting environments.
END
my $ampache_caution={
Name => 'ampache_caution',
Result =>
$Net::FullAuto::ISets::Local::Ampache_is::ampache_choose_site_profile,
#$Net::FullAuto::ISets::Local::Ampache_is::ampache_license_agreement_one,
Banner => $inform_banner,
};
return $ampache_caution;
};
our $ampache_license_agreement_three=sub {
package ampache_license_agreement_three;
my $ampache_license_banner_three=<<'END';
THIS FREE SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
EVENT SHALL THE AUTHOR OR ANY CONTRIBUTOR BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
EFFECTS OF UNAUTHORIZED OR MALICIOUS NETWORK ACCESS;
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
END
my %ampache_license_three=(
Name => 'ampache_license_three',
Item_1 => {
Text => "I accept the AMPACHE License Agreement",
Result =>
$Net::FullAuto::ISets::Local::Ampache_is::ampache_pick_email_address,
},
Item_2 => {
( run in 0.572 second using v1.01-cache-2.11-cpan-140bd7fdf52 )