picloud now can be configured from config
service fix
This commit is contained in:
@@ -7,8 +7,8 @@ version=$2
|
|||||||
if [ "$action" = "configure" ]; then
|
if [ "$action" = "configure" ]; then
|
||||||
cp /opt/org.SHS.picloud/picloud.service /etc/systemd/system/
|
cp /opt/org.SHS.picloud/picloud.service /etc/systemd/system/
|
||||||
systemctl --system daemon-reload >/dev/null || true
|
systemctl --system daemon-reload >/dev/null || true
|
||||||
systemctl enable shs-server >/dev/null || true
|
systemctl enable picloud >/dev/null || true
|
||||||
systemctl start shs-server >/dev/null || true
|
systemctl start picloud >/dev/null || true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#dpkg-maintscript-helper rm_conffile /etc/network/if-up.d/openssh-server 1:7.9p1-1~ -- "$@"
|
#dpkg-maintscript-helper rm_conffile /etc/network/if-up.d/openssh-server 1:7.9p1-1~ -- "$@"
|
||||||
|
|||||||
@@ -5,11 +5,13 @@ action=$1
|
|||||||
version=$2
|
version=$2
|
||||||
|
|
||||||
if [ "$action" = "install" ]; then
|
if [ "$action" = "install" ]; then
|
||||||
gr=dialout
|
if ! id shs &>/dev/null; then
|
||||||
if grep -q gpio /etc/group; then
|
gr=dialout
|
||||||
gr=$gr,gpio
|
if grep -q gpio /etc/group; then
|
||||||
|
gr=$gr,gpio
|
||||||
|
fi
|
||||||
|
useradd --system --create-home --home-dir /var/lib/shs --shell /usr/sbin/nologin --groups $gr shs
|
||||||
fi
|
fi
|
||||||
useradd --system --create-home --home-dir /var/lib/shs --shell /usr/sbin/nologin --groups $gr shs
|
|
||||||
fi
|
fi
|
||||||
#if [ "$action" = upgrade ] || [ "$action" = install ]
|
#if [ "$action" = upgrade ] || [ "$action" = install ]
|
||||||
#then
|
#then
|
||||||
@@ -20,6 +22,4 @@ fi
|
|||||||
# fi
|
# fi
|
||||||
#fi
|
#fi
|
||||||
|
|
||||||
#dpkg-maintscript-helper rm_conffile /etc/network/if-up.d/openssh-server 1:7.9p1-1~ -- "$@"
|
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
@@ -38,6 +38,20 @@ void usage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PIString confDir() {
|
||||||
|
return
|
||||||
|
#ifdef WINDOWS
|
||||||
|
PIDir::home().path() + "/AppData/Local"
|
||||||
|
#elif defined(MAC_OS)
|
||||||
|
PIDir::home().path() + "/Library/Preferences"
|
||||||
|
#elif defined(ANDROID)
|
||||||
|
PIString(".")
|
||||||
|
#else
|
||||||
|
PIDir::home().path() + "/.config"
|
||||||
|
#endif
|
||||||
|
+ "/SHS";
|
||||||
|
}
|
||||||
|
|
||||||
int main (int argc, char * argv[]) {
|
int main (int argc, char * argv[]) {
|
||||||
PICLI cli(argc, argv);
|
PICLI cli(argc, argv);
|
||||||
cli.addArgument("help");
|
cli.addArgument("help");
|
||||||
@@ -50,8 +64,23 @@ int main (int argc, char * argv[]) {
|
|||||||
usage();
|
usage();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
PITimer status_timer;
|
|
||||||
PIEthernet::Address addr = PIEthernet::Address("0.0.0.0", 10101);
|
PIEthernet::Address addr = PIEthernet::Address("0.0.0.0", 10101);
|
||||||
|
|
||||||
|
PIString conf_path = confDir();
|
||||||
|
PIDir::make(conf_path);
|
||||||
|
conf_path += "/picloud.conf";
|
||||||
|
if (!PIFile::isExists(conf_path)) {
|
||||||
|
PIFile f(conf_path, PIIODevice::ReadWrite);
|
||||||
|
f << "ip = " << addr.ipString() << "\n"
|
||||||
|
<< "port = " << addr.port() << "\n";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
PIConfig conf(conf_path, PIIODevice::ReadOnly);
|
||||||
|
addr.setIP(conf.getValue("ip", addr.ipString()).toString());
|
||||||
|
addr.setPort(conf.getValue("port", addr.port()).toUShort());
|
||||||
|
}
|
||||||
|
|
||||||
|
PITimer status_timer;
|
||||||
if (cli.hasArgument("ip"))
|
if (cli.hasArgument("ip"))
|
||||||
addr.setIP(cli.argumentValue("ip"));
|
addr.setIP(cli.argumentValue("ip"));
|
||||||
if (cli.hasArgument("port"))
|
if (cli.hasArgument("port"))
|
||||||
|
|||||||
Reference in New Issue
Block a user