Merge branch 'main' into 'main'

add a protection to not allow running asusd in terminal

Closes #104

See merge request asus-linux/asusctl!64
This commit is contained in:
Luke Jones
2021-07-30 00:12:17 +00:00
3 changed files with 15 additions and 0 deletions

View File

@@ -20,6 +20,7 @@ use std::error::Error;
use std::io::Write;
use std::sync::Arc;
use std::sync::Mutex;
use std::env;
use daemon::ctrl_rog_bios::CtrlRogBios;
use std::convert::Into;
@@ -35,6 +36,18 @@ pub fn main() -> Result<(), Box<dyn std::error::Error>> {
.filter(None, LevelFilter::Info)
.init();
let is_service = match env::var_os("IS_SERVICE") {
Some(val) => val == "1",
None => false,
};
if !is_service {
println!("asusd schould be only run from the right systemd service");
println!("do not run in your terminal, if you need an logs please use journalctl -b -u asusd");
println!("asusd will now exit");
return Ok(());
}
info!(" daemon v{}", daemon::VERSION);
info!(" rog-anime v{}", rog_anime::VERSION);
info!(" rog-aura v{}", rog_aura::VERSION);

View File

@@ -3,6 +3,7 @@ Description=ASUS Notebook Control
After=basic.target syslog.target
[Service]
Environment=IS_SERVICE=1
ExecStart=/usr/bin/asusd
Restart=on-failure
Type=dbus

View File

@@ -5,6 +5,7 @@ StartLimitBurst=2
Before=display-manager.service
[Service]
Environment=IS_SERVICE=1
ExecStart=/usr/bin/asusd
Restart=on-failure
Restart=always