set('php_version', function () { return ask(' What PHP version to install? ', '8.2', ['8.1', '8.2']); }); set('db_type', function () { $supportedDbTypes = [ 'none', 'mysql', 'mariadb', 'postgresql', ]; return askChoice(' What DB to install? ', $supportedDbTypes, 1); }); task('provision:ssh:fix_root_permissions', function () { $file = '/root/.ssh/authorized_keys'; $temp_file = '/root/.ssh/temp_keys'; run("sudo cp $file $temp_file"); run("sudo sed '/Please login as the user \\\\\"ubuntu\\\\\" rather than the user \\\\\"root\\\\\"./d' $temp_file > $file"); }); task('provision:ssh:fix_deployer_permissions', function () { $file = '/home/deployer/.ssh/authorized_keys'; $temp_file = '/home/deployer/.ssh/temp_keys'; run("sudo cp $file $temp_file"); run("sudo sed '/Please login as the user \\\\\"ubuntu\\\\\" rather than the user \\\\\"root\\\\\"./d' $temp_file > $file"); }); task('provision:fix_permissions', [ 'provision:ssh:fix_root_permissions', 'provision:ssh:fix_deployer_permissions', ]); task('provision:ssh:enable_root_login', function () { $file = '/etc/ssh/sshd_config'; run("echo 'PermitRootLogin yes' | sudo tee -a $file"); run('sudo systemctl restart sshd'); }); task('provision:ssh:deployer_nopass', function () { run("echo 'deployer ALL=(ALL) NOPASSWD:ALL' | sudo EDITOR='tee -a' visudo"); }); task('provision:website:fix', function () { set('remote_user', 'deployer'); run("[ -d {{deploy_path}} ] || mkdir -p {{deploy_path}}"); }); before('provision:website:fix', 'provision:fix_permissions'); before('provision:website:fix', 'provision:ssh:enable_root_login'); before('provision:website:fix', 'provision:ssh:deployer_nopass'); before('provision:website', 'provision:website:fix'); set('ssh_copy_id', '~/.ssh/id_ed25519.pub');