Commit 8271177a authored by Pavel Vainerman's avatar Pavel Vainerman

Подправил скрипты, чтобы они возвращали корректный значения завершения для…

Подправил скрипты, чтобы они возвращали корректный значения завершения для использования в скриптах на bash..
parent f7788ecf
...@@ -128,172 +128,170 @@ int main(int argc, char** argv) ...@@ -128,172 +128,170 @@ int main(int argc, char** argv)
int optindex = 0; int optindex = 0;
char opt = 0; char opt = 0;
while( (opt = getopt_long(argc, argv, "hc:beomsfur:l:i:x:g:w:y:p:",longopts,&optindex)) != -1 )
while( (opt = getopt_long(argc, argv, "hc:beomsfur:l:i:x:g:w:y:p:",longopts,&optindex)) != -1 )
{
switch (opt) //разбираем параметры
{ {
case 'h': //--help switch (opt) //разбираем параметры
usage();
return 0;
case 'c': //--confile
conffile = optarg;
break;
case 'o': //--omap
{ {
uniset_init(argc,argv,conffile); case 'h': //--help
return omap(); usage();
} return 0;
break;
case 'b': //--create case 'c': //--confile
{ conffile = optarg;
uniset_init(argc,argv,conffile); break;
createSections(conf);
}
return 0;
case 'm': //--msgmap case 'o': //--omap
{ {
uniset_init(argc,argv,conffile); uniset_init(argc,argv,conffile);
return msgmap(); return omap();
} }
break; break;
case 'x': //--setValue case 'b': //--create
{ {
uniset_init(argc,argv,conffile); uniset_init(argc,argv,conffile);
UniversalInterface ui(conf); createSections(conf);
return setValue(optarg,ui); }
} return 0;
break;
case 'g': //--getValue case 'm': //--msgmap
{ {
// cout<<"(main):received option --getValue='"<<optarg<<"'"<<endl; uniset_init(argc,argv,conffile);
uniset_init(argc,argv,conffile); return msgmap();
UniversalInterface ui(conf); }
return getValue(optarg,ui); break;
}
break;
case 'w': //--getRawValue case 'x': //--setValue
{ {
// cout<<"(main):received option --getRawValue='"<<optarg<<"'"<<endl; uniset_init(argc,argv,conffile);
uniset_init(argc,argv,conffile); UniversalInterface ui(conf);
UniversalInterface ui(conf); return setValue(optarg,ui);
return getRawValue(optarg,ui); }
} break;
break;
case 'p': //--oinfo case 'g': //--getValue
{ {
// cout<<"(main):received option --oinfo='"<<optarg<<"'"<<endl; // cout<<"(main):received option --getValue='"<<optarg<<"'"<<endl;
uniset_init(argc,argv,conffile); uniset_init(argc,argv,conffile);
UniversalInterface ui(conf); UniversalInterface ui(conf);
return oinfo(optarg,ui); return getValue(optarg,ui);
} }
break; break;
case 'e': //--exist case 'w': //--getRawValue
{ {
// cout<<"(main):received option --exist"<<endl; // cout<<"(main):received option --getRawValue='"<<optarg<<"'"<<endl;
uniset_init(argc,argv,conffile); uniset_init(argc,argv,conffile);
UniversalInterface ui(conf); UniversalInterface ui(conf);
return getRawValue(optarg,ui);
Command cmd=Exist; }
ObjectRepository* rep = new ObjectRepository(conf); break;
commandToAll(conf->getServicesSection(), rep, (Command)cmd);
commandToAll(conf->getControllersSection(), rep, (Command)cmd);
commandToAll(conf->getObjectsSection(), rep, (Command)cmd);
delete rep;
// cout<<"(exist): done"<<endl;
}
return 0;
case 's': //--start case 'p': //--oinfo
{ {
// cout<<"(main):received option --start"<<endl; // cout<<"(main):received option --oinfo='"<<optarg<<"'"<<endl;
uniset_init(argc,argv,conffile); uniset_init(argc,argv,conffile);
UniversalInterface ui(conf); UniversalInterface ui(conf);
return oinfo(optarg,ui);
}
break;
case 'e': //--exist
{
// cout<<"(main):received option --exist"<<endl;
uniset_init(argc,argv,conffile);
UniversalInterface ui(conf);
Command cmd=StartUp; Command cmd=Exist;
ObjectRepository* rep = new ObjectRepository(conf); ObjectRepository* rep = new ObjectRepository(conf);
commandToAll(conf->getServicesSection(), rep, (Command)cmd); commandToAll(conf->getServicesSection(), rep, (Command)cmd);
commandToAll(conf->getControllersSection(), rep, (Command)cmd); commandToAll(conf->getControllersSection(), rep, (Command)cmd);
commandToAll(conf->getObjectsSection(), rep, (Command)cmd); commandToAll(conf->getObjectsSection(), rep, (Command)cmd);
delete rep; delete rep;
} // cout<<"(exist): done"<<endl;
return 0; }
return 0;
case 'r': //--configure case 's': //--start
{ {
uniset_init(argc,argv,conffile); // cout<<"(main):received option --start"<<endl;
UniversalInterface ui(conf); uniset_init(argc,argv,conffile);
return configure(optarg,ui); UniversalInterface ui(conf);
}
break; Command cmd=StartUp;
ObjectRepository* rep = new ObjectRepository(conf);
commandToAll(conf->getServicesSection(), rep, (Command)cmd);
commandToAll(conf->getControllersSection(), rep, (Command)cmd);
commandToAll(conf->getObjectsSection(), rep, (Command)cmd);
delete rep;
}
return 0;
case 'f': //--finish case 'r': //--configure
{ {
// cout<<"(main):received option --finish"<<endl; uniset_init(argc,argv,conffile);
uniset_init(argc,argv,conffile); UniversalInterface ui(conf);
UniversalInterface ui(conf); return configure(optarg,ui);
}
Command cmd=Finish; break;
ObjectRepository* rep = new ObjectRepository(conf);
commandToAll(conf->getServicesSection(), rep, (Command)cmd);
commandToAll(conf->getControllersSection(), rep, (Command)cmd);
commandToAll(conf->getObjectsSection(), rep, (Command)cmd);
delete rep;
cout<<"(finish): done"<<endl;
}
return 0;
case 'l': //--logrotate case 'f': //--finish
{ {
uniset_init(argc,argv,conffile); // cout<<"(main):received option --finish"<<endl;
UniversalInterface ui(conf); uniset_init(argc,argv,conffile);
return logRotate(optarg, ui); UniversalInterface ui(conf);
}
break; Command cmd=Finish;
ObjectRepository* rep = new ObjectRepository(conf);
commandToAll(conf->getServicesSection(), rep, (Command)cmd);
commandToAll(conf->getControllersSection(), rep, (Command)cmd);
commandToAll(conf->getObjectsSection(), rep, (Command)cmd);
delete rep;
cout<<"(finish): done"<<endl;
}
return 0;
case 'y': //--getCalibrate case 'l': //--logrotate
{ {
// cout<<"(main):received option --getCalibrate='"<<optarg<<"'"<<endl; uniset_init(argc,argv,conffile);
uniset_init(argc,argv,conffile); UniversalInterface ui(conf);
UniversalInterface ui(conf); return logRotate(optarg, ui);
return getCalibrate(optarg, ui); }
} break;
break;
case 'u': //--foldUp case 'y': //--getCalibrate
{ {
// cout<<"(main):received option --foldUp"<<endl; // cout<<"(main):received option --getCalibrate='"<<optarg<<"'"<<endl;
uniset_init(argc,argv,conffile); uniset_init(argc,argv,conffile);
UniversalInterface ui(conf); UniversalInterface ui(conf);
return getCalibrate(optarg, ui);
Command cmd=FoldUp; }
ObjectRepository* rep = new ObjectRepository(conf); break;
commandToAll(conf->getServicesSection(), rep, (Command)cmd);
commandToAll(conf->getControllersSection(), rep, (Command)cmd);
commandToAll(conf->getObjectsSection(), rep, (Command)cmd);
delete rep;
// cout<<"(foldUp): done"<<endl;
}
return 0;
case '?': case 'u': //--foldUp
default: {
{ // cout<<"(main):received option --foldUp"<<endl;
short_usage(); uniset_init(argc,argv,conffile);
UniversalInterface ui(conf);
Command cmd=FoldUp;
ObjectRepository* rep = new ObjectRepository(conf);
commandToAll(conf->getServicesSection(), rep, (Command)cmd);
commandToAll(conf->getControllersSection(), rep, (Command)cmd);
commandToAll(conf->getObjectsSection(), rep, (Command)cmd);
delete rep;
// cout<<"(foldUp): done"<<endl;
}
return 0; return 0;
case '?':
default:
{
short_usage();
return 1;
}
} }
}
}
}
return 0; return 0;
} }
...@@ -320,6 +318,8 @@ int main(int argc, char** argv) ...@@ -320,6 +318,8 @@ int main(int argc, char** argv)
{ {
cerr << "неизвестное исключение" << endl; cerr << "неизвестное исключение" << endl;
} }
return 1;
} }
// ============================================================================================== // ==============================================================================================
...@@ -507,11 +507,11 @@ int setValue( const string args, UniversalInterface &ui, Configuration* conf ) ...@@ -507,11 +507,11 @@ int setValue( const string args, UniversalInterface &ui, Configuration* conf )
switch(t) switch(t)
{ {
case UniversalIO::DigitalInput: case UniversalIO::DigitalInput:
ui.saveState(it->si.id,(it->val?true:false),t,it->si.node); ui.saveState(it->si.id,(it->val?true:false),t,it->si.node);
break; break;
case UniversalIO::DigitalOutput: case UniversalIO::DigitalOutput:
ui.setState(it->si.id,(it->val?true:false),it->si.node); ui.setState(it->si.id,(it->val?true:false),it->si.node);
break; break;
case UniversalIO::AnalogInput: case UniversalIO::AnalogInput:
......
#!/bin/sh #!/bin/sh
./uniset-start.sh -f "./uniset-admin --confile test.xml --`basename $0 .sh` $1 $2 $3 $4" ./uniset-start.sh -f "./uniset-admin --confile test.xml --`basename $0 .sh` $1 $2 $3 $4"
exit $?
...@@ -60,7 +60,7 @@ then ...@@ -60,7 +60,7 @@ then
echo Running "$start_line" echo Running "$start_line"
$start_line $start_line
exit 0 exit $?
fi fi
if [ -n "$FG" ] if [ -n "$FG" ]
...@@ -69,20 +69,19 @@ then ...@@ -69,20 +69,19 @@ then
if [ -z "$COMLINE" ] if [ -z "$COMLINE" ]
then then
echo "Не указана команда для запуска" echo "Не указана команда для запуска"
exit 0 exit 1
fi fi
COMLINE="$COMLINE --uniset-port $OMNIPORT" COMLINE="$COMLINE --uniset-port $OMNIPORT"
echo Запускаем "$COMLINE" echo Запускаем "$COMLINE"
$COMLINE $COMLINE
echo Выходим exit $?
exit 1
fi fi
if [ -z "$*" ] if [ -z "$*" ]
then then
echo "Не указана команда для запуска" echo "Не указана команда для запуска"
exit 0 exit 1
fi fi
checkPID=$(echo "$1" | grep pidfile=) checkPID=$(echo "$1" | grep pidfile=)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment