I created the following script to send me an email on startup, placed it in "/usr/lib/systemd/scripts"
$this->bbcode_second_pass_code('', '
import smtplib
import socket
GMAIL_ADDR = "XXXX"
GMAIL_PW = "XXXX"
TO_ADDR = "XXXX"'
my_ip = socket.gethostbyname(socket.gethostname())
server = smtplib.SMTP("smtp.gmail.com", 587)
server.starttls()
server.login(GMAIL_ADDR, GMAIL_PW)
server.sendmail(GMAIL_ADDR, TO_ADDR, "Raspberry Pie is located at %s" % my_ip)
server.quit()
')
I created the following service and placed in in /usr/lib/systemd/system
$this->bbcode_second_pass_code('', '[Unit]
Description=mail ip on boot
[Service]
Type=oneshot
ExecStart=/usr/lib/systemd/scripts/mail_ip
[Install]
WantedBy=multi-user.target')
The script runs locally but when I boot up I get the following
$this->bbcode_second_pass_code('', '
UNIT LOAD ACTIVE SUB DESCRIPTION
mail_ip.service loaded failed failed mail ip on boot
')
Could it have something to do with the network not being ready yet? Is there any good ways to debug this problem?
Thanks