From cbc197c01ee18b103ced59792da5290c4d11eebc Mon Sep 17 00:00:00 2001 From: anmol26s Date: Wed, 19 Sep 2018 17:23:29 +0530 Subject: [PATCH] test spawn to input commands --- conf/first_run.exp | 63 ++++++++++++++++++++++++++++++++++++++++++++++ scripts/install | 25 +++++++++--------- 2 files changed, 75 insertions(+), 13 deletions(-) create mode 100644 conf/first_run.exp diff --git a/conf/first_run.exp b/conf/first_run.exp new file mode 100644 index 0000000..c54de6c --- /dev/null +++ b/conf/first_run.exp @@ -0,0 +1,63 @@ +#!/usr/bin/expect +set timeout 10 + +set final_path [lindex $argv 0] +set domain [lindex $argv 1] +set blog_name [lindex $argv 2] +set admin [lindex $argv 3] +set email [lindex $argv 4] +set port [lindex $argv 5] + + + +spawn cd $final_path && cargo run + +expect "First let's check that you have all the required dependencies. Press Enter to start." + +send "\r"; + +expect "Password:" + +send {__PASSWORD__}; + +send "\r"; + +expect "Do you prefer a simple setup, or to customize everything? + 1 - Simple setup + 2 - Complete setup" + +send "2\r"; + +expect "What is your instance domain?" + +send "$domain\r"; + +expect "What is your instance name?" + +send "$blog_name\r"; + +expect "What is your username? (default: admin)" + +send "$admin\r"; + +expect "What is your email?" + +send "$email\r"; + +expect "What is your password?" + +send {__ADMIN_PASS__}; + +send "\r"; + +expect "On which port should Plume listen? (default: 7878)" + +send "$port\r"; + +expect "On which address should Plume listen? (default: 0.0.0.0)" + +send "127.0.0.1\r"; + +sleep 10 + +interact diff --git a/scripts/install b/scripts/install index 4b78f57..fad5eb6 100755 --- a/scripts/install +++ b/scripts/install @@ -160,24 +160,23 @@ ynh_replace_string "__DB_USER__" "$app" "$final_path/.env" # Set right permissions chown -R $app: $final_path -# Try Here string to input +# spawn test pass="test" -name="test" +blog_name="test" +admin="test" email="test@domain.tld" admin_pass="test123" -( cd $final_path && cargo run << EOF +# Copy first run script +cp ../conf/first_run.exp $final_path +chmod +x $final_path/first_run.exp -$pass -2 -$domain -$username -$email -$admin_pass -$port -127.0.0.1 -EOF -) + +# We escape all char witch needed. +ynh_replace_special_string "__PASSWORD__" $pass "$final_path/first_run.exp" +ynh_replace_special_string "__ADMIN_PASS__" $admin_pass "$final_path/first_run.exp" +su - $app -s /bin/bash -c "$final_path/first_run.exp $final_path $domain $blog_name $admin $email $port" +ynh_secure_remove "$final_path/first_launch.exp" #================================================= # SETUP SYSTEMD