2023-11-08 08:25:45 +00:00
#!/bin/bash
2023-11-08 13:56:03 +00:00
port = 21
ip = $( hostname -I | awk '{print $1}' )
2023-11-08 08:25:45 +00:00
# Check if the port is in use
if nc -z localhost $port ; then
zenity --error --no-wrap \
--window-icon= "/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
--title "RetroDECK - FTP Server" \
--text= " Port $port is already in use. Please stop any services on that port and try again. "
exit 1
fi
# Start FTP server on port $port
2023-11-08 13:56:03 +00:00
nohup vsftpd /var/config/retrodeck/ftp/vsftpd.conf &
2023-11-08 08:25:45 +00:00
# Get the PID of the FTP server process
ftp_pid = $!
# Function to stop the FTP server
stop_ftp_server( ) {
kill -9 $ftp_pid
exit 0
}
# Create a Zenity window with only the "Stop" button
zenity --icon-name= net.retrodeck.retrodeck --info --no-wrap \
--window-icon= "/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
--title "RetroDECK - FTP Server" \
2023-11-08 13:56:03 +00:00
--text= " FTP server started.\n\nAddress: $ip \nport: $port \nID:\tretrodeck\nPassword:\tretrodeck\npointing to:\n $rdhome \n\nPress Stop to terminate the server. " --ok-label= "Stop" || stop_ftp_server
2023-11-08 08:25:45 +00:00
# If the user clicks "Stop", call the function to stop the FTP server
stop_ftp_server