Net-FullAuto
view release on metacpan or search on metacpan
lib/Net/FullAuto/ISets/Local/ClipBucket_is.pm view on Meta::CPAN
#($stdout,$stderr)=$handle->cmd($sudo.
# 'rm -rvf /opt/source/sql_mode.cnf','__display__');
($stdout,$stderr)=$handle->cmd($sudo.
'service mysql start','__display__');
($stdout,$stderr)=$handle->cmd($sudo.
'chmod -v 711 /var/lib/mysql/mysql','__display__');
print "MYSQL START STDOUT=$stdout and STDERR=$stderr<==\n";sleep 5;
print "\n\n\n\n\n\n\nWE SHOULD HAVE INSTALLED MARIADB=$stdout<==\n\n\n\n\n\n\n";
sleep 5;
}
($stdout,$stderr)=$handle->cmd("uname -a");
if ($stdout=~/Ubuntu/i) {
($stdout,$stderr)=$handle->cmd($sudo.
'apt-get -y install git-all','__display__');
} else {
($stdout,$stderr)=$handle->cmd($sudo.
'yum -y -v install git-all','__display__');
}
($stdout,$stderr)=$handle->cwd('/opt/source/');
#https://community.letsencrypt.org/t/help-with-certbot-on-the-new-amazon-linux-2/49399/7
($stdout,$stderr)=$handle->cmd('wget https://dl.eff.org/certbot-auto');
($stdout,$stderr)=$handle->cmd('chmod -v a+x certbot-auto','__display__');
my $ad='%SP%%SP%}%NL%'.
' BOOTSTRAP_VERSION="BootstrapRpmCommon $BOOTSTRAP_RPM_COMMON_VERSION"%NL%'.
'elif grep -i "Amazon Linux" /etc/issue > /dev/null 2>&1 || \%NL%'.
' grep %SQ%cpe:.*:amazon_linux:2%SQ% /etc/os-release > /dev/null 2>&1; then%NL%'.
' Bootstrap() {%NL%'.
' ExperimentalBootstrap "Amazon Linux" BootstrapRpmCommon%NL%'.
' }%NL%'.
' BOOTSTRAP_VERSION="BootstrapRpmCommon $BOOTSTRAP_RPM_COMMON_VERSION"';
($stdout,$stderr)=$handle->cmd(
"sed -i -e '/Amazon Linux. BootstrapRpmCommon/{n;N;d}' certbot-auto");
($stdout,$stderr)=$handle->cmd(
"${sudo}sed -i \'/Amazon Linux. BootstrapRpmCommon/a$ad\' certbot-auto");
($stdout,$stderr)=$handle->cmd(
"${sudo}sed -i \'s/%NL%/\'\"`echo \\\\\\n`/g\" ".
'certbot-auto');
($stdout,$stderr)=$handle->cmd(
"${sudo}sed -i \'s/%SP%/ /g\' ".
'certbot-auto');
($stdout,$stderr)=$handle->cmd("${sudo}sed -i \"s/%SQ%/\'/g\" ".
'certbot-auto');
($stdout,$stderr)=$handle->cmd($sudo.
'git clone https://github.com/arslancb/clipbucket.git','__display__');
($stdout,$stderr)=$handle->cwd("clipbucket");
($stdout,$stderr)=$handle->cmd(
'git tag | sort -n | tail -1','__display__');
chomp($stdout);
# git ls-remote --tags git://github.com/arslancb/clipbucket
($stdout,$stderr)=$handle->cmd($sudo.
"git checkout $stdout",'__display__');
($stdout,$stderr)=$handle->cwd("upload");
($stdout,$stderr)=$handle->cmd($sudo.'mkdir -vp /var/www/html',
'__display__');
($stdout,$stderr)=$handle->cmd($sudo.'chmod 777 /var','__display__');
($stdout,$stderr)=$handle->cmd($sudo.
'cp -Rv . /var/www/html/clipbucket','__display__');
($stdout,$stderr)=$handle->cmd($sudo.
'chmod -Rv 775 /var/www','__display__');
($stdout,$stderr)=$handle->cmd($sudo.
'chown -Rv www-data:www-data /var/www','__display__');
($stdout,$stderr)=$handle->cmd($sudo.
'chmod -Rv 777 /var/www/html/clipbucket/cache','__display__');
($stdout,$stderr)=$handle->cmd($sudo.
'chmod -Rv 777 /var/www/html/clipbucket/files','__display__');
($stdout,$stderr)=$handle->cmd($sudo.
'chmod -Rv 777 /var/www/html/clipbucket/images','__display__');
($stdout,$stderr)=$handle->cmd($sudo.
'chmod -Rv 777 /var/www/html/clipbucket/includes','__display__');
my $fa_builddir=fullauto_builddir($local,$sudo);
my $ignore='';
($ignore,$stdout)=$local->cmd("${sudo}cp -v $fa_builddir/installer/".
'fullauto_clickable_image.png /opt/source','__display__');
($ignore,$stdout)=$local->cmd($sudo.
'chmod -v 777 fullauto_clickable_image.png','__display__');
($stdout,$stderr)=$handle->cwd('/opt/source');
#($stdout,$stderr)=$handle->put('fullauto_clickable_image.png');
($stdout,$stderr)=$handle->cmd($sudo.
'chmod -v 777 fullauto_clickable_image.png','__display__');
($stdout,$stderr)=$handle->cwd('/opt/source');
my $sd='/var/www/html/clipbucket/styles/cb_28/theme/images';
($stdout,$stderr)=$handle->cmd($sudo.
"mv -vf fullauto_clickable_image.png $sd",'__display__');
($stdout,$stderr)=$local->cmd($sudo.
"rm -rvf fullauto_clickable_image.png",'__display__');
($stdout,$stderr)=$handle->cmd($sudo.
$sudo.'chmod -Rv 777 /var/www/html/clipbucket/styles','__display__');
my $fullstyle=
' <div class="fullauto">%NL%'.
' <a href="http://www.fullauto.com">%NL%'.
' <img src="{$theme}/images/fullauto_clickable_image.png" class="fullauto-image">%NL%'.
' </a>%NL%'.
' </div>%NL%';
$ad=<<END;
sed -i '/Collect/i$fullstyle' /var/www/html/clipbucket/styles/cb_28/layout/header.html
END
$handle->cmd_raw("${sudo}$ad");
($stdout,$stderr)=$handle->cmd(
"${sudo}sed -i \'s/%NL%/\'\"`echo \\\\\\n`/g\" ".
"/var/www/html/clipbucket/styles/cb_28/layout/header.html");
$handle->cmd_raw(
"${sudo}sed -i 's/\\(^[<]div.*\\\)/ \\1/' ".
"/var/www/html/clipbucket/styles/cb_28/layout/header.html");
$fullstyle=
'<style>%NL%'.
'.fullauto{%NL%'.
' padding: 10px 10px;%NL%'.
' float: none;%NL%'.
' display: table-cell;%NL%'.
' vertical-align: middle;%NL%'.
' width: 40px;%NL%'.
'}%NL%'.
'.fullauto-image {%NL%'.
' display: block;%NL%'.
' position: relative;%NL%'.
' width: 83px;%NL%'.
' height: 40px;%NL%'.
'}%NL%'.
'</style>%NL%';
$ad=<<END;
sed -i '/^[<]script[>]/i$fullstyle' /var/www/html/clipbucket/styles/cb_28/layout/header.html
lib/Net/FullAuto/ISets/Local/ClipBucket_is.pm view on Meta::CPAN
}
configtest() {
\\x24nginx -t -c \\x24NGINX_CONF_FILE
}
rh_status() {
status \\x24prog
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
case \\x22\\x241\\x22 in
start)
rh_status_q && exit 0
\\x241
;;
stop)
rh_status_q || exit 0
\\x241
;;
restart|configtest)
\\x241
;;
reload)
rh_status_q || exit 7
\\x241
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
;;
\\x2A)
echo \\x24\\x22Usage: \\x240 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}\\x22
exit 2
esac
END
($stdout,$stderr)=$handle->cmd(
"echo -e \"$nginxconf\" > /opt/source/nginx");
($stdout,$stderr)=$handle->cmd($sudo.
'cp -v /opt/source/nginx /etc/init.d','__display__');
($stdout,$stderr)=$handle->cmd($sudo.
'chmod -v 755 /etc/init.d/nginx','__display__');
($stdout,$stderr)=$handle->cmd($sudo.
'systemctl daemon-reload','__display__');
($stdout,$stderr)=$handle->cmd($sudo.
'service nginx start','__display__');
($stdout,$stderr)=$handle->cmd($sudo.
"sed -i 's|^plugin-load-add=auth_gssapi.so|".
"#plugin-load-add=auth_gssapi.so|' ".
'/etc/my.cnf.d/auth_gssapi.cnf');
# HOW TO CHECK MYSQL FOR ERRORS
# mkdir /var/run/mysqld/
# chown mysql: /var/run/mysqld/
# mysqld --basedir=/usr --datadir=/var/lib/mysql
# --user=mysql --socket=/var/run/mysqld/mysqld.sock
$handle->{_cmd_handle}->print($sudo.'mysql_secure_installation');
$prompt=substr($handle->{_cmd_handle}->prompt(),1,-1);
while (1) {
my $output=Net::FullAuto::FA_Core::fetch($handle);
last if $output=~/$prompt/;
print $output;
if (-1<index $output,'root (enter for none):') {
$handle->{_cmd_handle}->print();
next;
} elsif (-1<index $output,'so you can safely answer \'n\'') {
$handle->{_cmd_handle}->print('n');
next;
} elsif (-1<index $output,'Set root password? [Y/n]') {
$handle->{_cmd_handle}->print('n');
next;
} elsif (-1<index $output,'Remove anonymous users? [Y/n]') {
$handle->{_cmd_handle}->print('Y');
next;
} elsif (-1<index $output,'Disallow root login remotely? [Y/n]') {
$handle->{_cmd_handle}->print('Y');
next;
} elsif (-1<index $output,
'Remove test database and access to it? [Y/n]') {
$handle->{_cmd_handle}->print('Y');
next;
} elsif (-1<index $output,'Reload privilege tables now? [Y/n]') {
$handle->{_cmd_handle}->print('Y');
next;
}
}
$handle->cmd("echo");
$handle->{_cmd_handle}->print($sudo.'mysql -u root -p 2>&1');
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,'Enter password:') {
$handle->{_cmd_handle}->print();
next;
} elsif (-1<index $output,'none') {
if (!$first_pass) {
$handle->{_cmd_handle}->print('CREATE DATABASE clipbucket;');
$first_pass=1;
} elsif (!$second_pass) {
$handle->{_cmd_handle}->print(
'GRANT USAGE ON clipbucket.* TO clipbucket@localhost'.
" IDENTIFIED BY \'$service_and_cert_password\';");
$second_pass=1;
} elsif (!$third_pass) {
$handle->{_cmd_handle}->print(
'GRANT FILE ON *.* TO clipbucket@localhost;');
} elsif (!$fourth_pass) {
$handle->{_cmd_handle}->print(
lib/Net/FullAuto/ISets/Local/ClipBucket_is.pm view on Meta::CPAN
'__display__');
($stdout,$stderr)=$handle->cmd($sudo.
'yum -y install gmp-devel.x86_64',
'__display__');
($stdout,$stderr)=$handle->cmd($sudo.
'yum -y install m4 fuse fuse-devel libcurl-devel libsqlite3x-devel zlib-devel',
'__display__');
($stdout,$stderr)=$handle->cmd($sudo.
'yum -y install bubblewrap',
'__display__');
($stdout,$stderr)=$handle->cwd('~');
($stdout,$stderr)=$handle->cmd(
'git clone https://github.com/OCamlPro/opam.git','__display__');
($stdout,$stderr)=$handle->cwd('opam');
($stdout,$stderr)=$handle->cmd('make lib-ext','__display__');
($stdout,$stderr)=$handle->cmd('./configure','__display__');
($stdout,$stderr)=$handle->cmd('make lib-ext','__display__');
($stdout,$stderr)=$handle->cmd('make','__display__');
($stdout,$stderr)=$handle->cmd($sudo.'make install','__display__');
($stdout,$stderr)=$handle->cwd('..');
$handle->{_cmd_handle}->print('opam init');
$prompt=substr($handle->{_cmd_handle}->prompt(),1,-1);
$prompt=~s/\$$//;
my $m=1;
while ($m==1) {
my $output.=Net::FullAuto::FA_Core::fetch($handle);
last if $output=~/$prompt/;
print $output;
if (-1<index $output,'choose a different') {
$handle->{_cmd_handle}->print('y');
$output='';
next;
} elsif (-1<index $output,'Set that up') {
$handle->{_cmd_handle}->print('y');
$output='';
next;
}
}
($stdout,$stderr)=$handle->cmd(
'opam update','__display__');
print "\n\n EXPECT *** LONG **** DELAY - up to 10 minutes ...\n\n";
($stdout,$stderr)=$handle->cmd(
'opam switch create ocaml-base-compiler',600,'__display__');
$handle->{_cmd_handle}->print('opam install google-drive-ocamlfuse');
$prompt=substr($handle->{_cmd_handle}->prompt(),1,-1);
$prompt=~s/\$$//;
my $n=1;
while ($n==1) {
my $output.=Net::FullAuto::FA_Core::fetch($handle);
last if $output=~/$prompt/;
print $output;
if (-1<index $output,'want to continue') {
$handle->{_cmd_handle}->print('Y');
$output='';
next;
}
}
($stdout,$stderr)=$handle->cmd($sudo.
'mkdir -vp /google-drive','__display__');
($stdout,$stderr)=$handle->cmd($sudo.
'chown -v ec2-user:ec2-user /google-drive','__display__');
my $substitute_email_module='%NL%'.
'#####################################################%NL%'.
'# Inserted by FullAuto to handle Amazon SES passwords%NL%'.
'#####################################################%NL%%NL%'.
'require_once %SQ%Mail.php%SQ%;%NL%'.
'%NL%'.
'$headers = array (%NL%'.
' %SQ%From%SQ% => $from,%NL%'.
' %SQ%To%SQ% => $to,%NL%'.
' %SQ%Subject%SQ% => $subject,%NL%'.
' %SQ%MIME-Version%SQ% => "1.0",%NL%'.
' %SQ%Content-Type%SQ% => "text/html; charset=iso-8859-1"%NL%'.
');%NL%'.
'%NL%'.
'$smtpParams = array (%NL%'.
' %SQ%host%SQ% => $mail->Host,%NL%'.
' %SQ%port%SQ% => $mail->Port,%NL%'.
' %SQ%auth%SQ% => true,%NL%'.
' %SQ%username%SQ% => $mail->Username,%NL%'.
' %SQ%password%SQ% => $mail->Password%NL%'.
');%NL%'.
'%NL%'.
' // Create an SMTP client.%NL%'.
'$mail = Mail::factory(%SQ%smtp%SQ%, $smtpParams);%NL%'.
'%NL%'.
'// Send the email.%NL%'.
'$result = $mail->send($to, $headers, $message);%NL%'.
'%NL%'.
'#if (PEAR::isError($result)) {%NL%'.
'# echo("Email not sent. " .$result->getMessage() ."\\n");%NL%'.
'#} else {%NL%'.
'# echo("Email sent!"."\\n");%NL%'.
'#}%NL%%NL%'.
'####################################################%NL%'.
'# Commented Out by FullAuto so above sends all email%NL%'.
'####################################################%NL%';
($stdout,$stderr)=$handle->cwd("/var/www/html/clipbucket/includes");
($stdout,$stderr)=$handle->cmd("${sudo}sed -i ".
"\'/MsgHTML/i$substitute_email_module\' functions.php");
($stdout,$stderr)=$handle->cmd(
"${sudo}sed -i \'s/%NL%/\'\"`echo \\\\\\n`/g\" ".
'functions.php');
($stdout,$stderr)=$handle->cmd("${sudo}sed -i \"s/%SQ%/\'/g\" ".
'functions.php');
($stdout,$stderr)=$handle->cmd("${sudo}sed -i ".
"'/MsgHTML/,+8 s/^/#/' ".
'functions.php');
($stdout,$stderr)=$handle->cmd($sudo.
"sed -i 's/webmaster\@website/".$verified_email."/' ".
'functions.php');
($stdout,$stderr)=$handle->cmd_raw('cat functions.php | sudo '.
'bash -ic "awk \'{ sub(/\r$/,\"\"); print }\' > temp.php"');
($stdout,$stderr)=$handle->cmd($sudo.
'mv -fv temp.php functions.php','__display__');
($stdout,$stderr)=$handle->cwd("/var/www/html/clipbucket/cb_install/sql");
my %smtp_host=('us-east-1' => 'email-smtp.us-east-1.amazonaws.com',
'us-west-2' => 'email-smtp.us-west-2.amazonaws.com',
'eu-west-1' => 'email-smtp.eu-west-1.amazonaws.com');
my $smtp_host='email-smtp.us-east-1.amazonaws.com';
$region=~s/^.*['](.*)[']$/$1/;
lib/Net/FullAuto/ISets/Local/ClipBucket_is.pm view on Meta::CPAN
($stdout,$stderr)=$handle->cmd($sudo.
"sed -i 's/root/clipbucket/' dbconnect.php");
($stdout,$stderr)=$handle->cmd($sudo.
"sed -i \"s/''/'".$service_and_cert_password."'/\" dbconnect.php");
#($stdout,$stderr)=$handle->cmd($sudo.
# 'rm -rvf /var/www/html/clipbucket/cb_install','__display__');
($stdout,$stderr)=$handle->cwd('/opt/source');
($stdout,$stderr)=$handle->cmd($sudo.
'chmod -Rv 755 /var/www/html/clipbucket/includes/','__display__');
$ad=<<'END';
\\x2A \\x2A \\x2A \\x2A \\x2A php -q /var/www/html/clipbucket/actions/video_convert.php
\\x2A \\x2A \\x2A \\x2A \\x2A php -q /var/www/html/clipbucket/actions/verify_converted_videos.php
0 0,12,13 \\x2A \\x2A \\x2A php -q /var/www/html/clipbucket/actions/update_cb_stats.php
END
($stdout,$stderr)=$handle->cmd("echo -e \"$ad\" > root");
($stdout,$stderr)=$handle->cmd($sudo.
'cp root /var/spool/cron/','__display__');
($stdout,$stderr)=$handle->cmd($sudo.
'rm -rvf root','__display__');
($stdout,$stderr)=$handle->cmd($sudo.
'service crond restart','__display__');
#($stdout,$stderr)=$handle->cmd($sudo.
# 'rm -rvf /var/www/html/clipbucket/files/temp/install.me','__display__');
use LWP::UserAgent;
use HTTP::Request::Common;
use IO::Socket::SSL qw();
my $Browser = LWP::UserAgent->new(
ssl_opts => {
SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE,
verify_hostname => 0,
}
);
my $starting_clipbucket=<<'END';
.oPYo. ooooo .oo .oPYo. ooooo o o o .oPYo. o o .oPYo.
8 8 .P 8 8 `8 8 8 8b 8 8 8 8 8 8 8
`Yooo. 8 .P 8 8YooP' 8 8 8`b 8 8 8 8 8YooP'
`8 8 oPooo8 8 `b 8 8 8 `b 8 8 oo 8 8 8
8 8 .P 8 8 8 8 8 8 `b8 8 8 8 8 8
`YooP' 8 .P 8 8 8 8 8 8 `8 `YooP8 `YooP' 8
....................................................................
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
http://clipbucket.com/
_____ _ _______ ____ _ _ _____ _ __ ______ _______
/ ____| | | | __ \| _ \| | | |/ ____| | / /| ____|__ __|
/ / | | | | |__) | |_) | | | | | | |/ / | |__ | |
| | | | | | ___/| _ <| | | | | | \ | __| | |
| \____| |____| | | | |_) | |__| | |____| |\ \| |____ | |
\_____|______|_|_| |____/ \____/ \_____|_| \__|______| |_|
(CLIPBUCKET is **NOT** a sponsor of the FullAuto© Project.)
END
print $starting_clipbucket;sleep 10;
($stdout,$stderr)=$handle->cmd($sudo.
'chown -Rv www-data:www-data /var/www','__display__');
$region=~s/^.*['](.*)[']$/$1/;
($stdout,$stderr)=$handle->cmd($sudo.'wget -qO- '.
'http://docs.aws.amazon.com/ses/latest/DeveloperGuide/smtp-connect.html'
);
my @smtp_servers=();my $smtp_server='us-east-1';
foreach my $line (split /\n/,$stdout) {
if (-1<index $line,'email-smtp.') {
$line=~s/^.*(email-smtp\.[^Hh].*?com).*$/$1/;
next unless $line=~/^email-smtp/;
push @smtp_servers,$line;
if (-1<index $line,$region) {
$smtp_server=$line;
last;
}
}
}
($stdout,$stderr)=$handle->cmd($sudo.
'touch /etc/mail/authinfo');
($stdout,$stderr)=$handle->cmd($sudo.
'chmod 666 /etc/mail/authinfo');
my $authinfo=<<END;
AuthInfo:$smtp_server \\x22U:root\\x22 \\x22I:$access_id\\x22 \\x22P:$smtppass\\x22 \\x22M:PLAIN\\x22
END
chop $authinfo;
($stdout,$stderr)=$handle->cmd($sudo.
"echo -e \"$authinfo\" > /etc/mail/authinfo");
($stdout,$stderr)=$handle->cmd($sudo.
'makemap -v hash /etc/mail/authinfo.db < /etc/mail/authinfo',
'__display__');
my $access="Connect:$smtp_server RELAY";
($stdout,$stderr)=$handle->cmd($sudo.
'chmod -v 666 /etc/mail/access');
($stdout,$stderr)=$handle->cmd($sudo.
"echo -e \"$access\" >> /etc/mail/access");
($stdout,$stderr)=$handle->cmd($sudo.
'chmod -v 644 /etc/mail/access');
my $email_domain=$verified_email;
$email_domain=~s/^.*\@(.*)$/$1/;
$ad="define(`SMART_HOST%SQ%, `$smtp_server%SQ%)dnl%NL%".
"define(`RELAY_MAILER_ARGS%SQ%, `TCP \$h 25%SQ%)dnl%NL%".
"define(`confAUTH_MECHANISMS%SQ%, `LOGIN PLAIN%SQ%)dnl%NL%".
"FEATURE(`authinfo%SQ%, `hash -o /etc/mail/authinfo.db%SQ%)dnl%NL%".
"MASQUERADE_AS(`$email_domain%SQ%)dnl%NL%".
"FEATURE(masquerade_envelope)dnl%NL%".
"FEATURE(masquerade_entire_domain)dnl";
($stdout,$stderr)=$handle->cmd($sudo."sed -i ".
"\'/MAILER(smtp)dnl/i$ad\' /etc/mail/sendmail.mc");
($stdout,$stderr)=$handle->cmd($sudo.
"sed -i \'s/%NL%/\'\"`echo \\\\\\n`/g\" ".
'/etc/mail/sendmail.mc');
($stdout,$stderr)=$handle->cmd($sudo.
"sed -i \"s/%SQ%/\'/g\" ".'/etc/mail/sendmail.mc');
($stdout,$stderr)=$handle->cmd($sudo.
"${sudo}chmod -v 666 /etc/mail/sendmail.cf",'__display__');
($stdout,$stderr)=$handle->cmd($sudo.
"${sudo}m4 -d /etc/mail/sendmail.mc > /etc/mail/sendmail.cf");
($stdout,$stderr)=$handle->cmd($sudo.
"${sudo}chmod -v 644 /etc/mail/sendmail.cf",'__display__');
($stdout,$stderr)=$handle->cmd($sudo.
'service sendmail restart','__display__');
( run in 1.156 second using v1.01-cache-2.11-cpan-71847e10f99 )