1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/plume_ynh.git synced 2024-09-03 20:15:54 +02:00

test spawn to input commands

This commit is contained in:
anmol26s 2018-09-19 17:23:29 +05:30
parent 4edc196390
commit cbc197c01e
2 changed files with 75 additions and 13 deletions

63
conf/first_run.exp Normal file
View file

@ -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

View file

@ -160,24 +160,23 @@ ynh_replace_string "__DB_USER__" "$app" "$final_path/.env"
# Set right permissions # Set right permissions
chown -R $app: $final_path chown -R $app: $final_path
# Try Here string to input # spawn test
pass="test" pass="test"
name="test" blog_name="test"
admin="test"
email="test@domain.tld" email="test@domain.tld"
admin_pass="test123" 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 # We escape all char witch needed.
$domain ynh_replace_special_string "__PASSWORD__" $pass "$final_path/first_run.exp"
$username ynh_replace_special_string "__ADMIN_PASS__" $admin_pass "$final_path/first_run.exp"
$email su - $app -s /bin/bash -c "$final_path/first_run.exp $final_path $domain $blog_name $admin $email $port"
$admin_pass ynh_secure_remove "$final_path/first_launch.exp"
$port
127.0.0.1
EOF
)
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD