/* |\/| /.\ | |\| */ int main(void) { static char* hostname ; hostname = status_hostname() ; char* ret ; if ( strcmp(hostname,"dream")==0 ) { wmfs_send_text(0, "%s%s%s%s%s%s%s%s%s", status_date(380, "%H:%M:%S"), status_mem(435), status_cpu(535), status_reseau(640), status_server(750), status_gmail(900), status_irc(1190), status_music(1310), status_sound(1620)); wmfs_send_text(1, "%s%s%s%s%s", status_date(380, "%H:%M:%S"), status_mem(435), status_cpu(535), status_music(910), status_sound(1220)); } else if ( strcmp(hostname,"ecafe\0")==0 ) { wmfs_send_text(0, "%s%s%s%s%s%s%s", status_date(380-85, "%H:%M:%S"), status_mem(435-80), status_cpu(535-80), status_reseau(640-80), status_gmail(900-80-150), status_irc(1190-80-250-50), status_sound(950)); } else { wmfs_send_text(-1, "Bad Trip ...." ); } return 0; }
static int run_status_server(int *rfd, int *cfd, int status_rfd, const char *conffile) { int ret=-1; struct conf *conf=NULL; close_fd(rfd); // Reload global config, in case things have changed. This means that // the server does not need to be restarted for most conf changes. if(!(conf=conf_alloc())) goto end; conf_init(conf); if(conf_load(conffile, conf, 1)) goto end; ret=status_server(cfd, status_rfd, conf); close_fd(cfd); end: logp("exit status server\n"); conf_free(conf); return ret; }
int child(struct async *as, int is_status_server, int status_wfd, struct conf **confs, struct conf **cconfs) { int ret=-1; int srestore=0; int timer_ret=0; char *incexc=NULL; const char *confs_user; const char *cconfs_user; const char *confs_group; const char *cconfs_group; const char *s_script_pre; const char *s_script_post; // If we are not a status server, we are a normal child - set up the // parent socket to write status to. if(status_wfd>0) { if(!(wasfd=setup_asfd(as, "child status pipe", &status_wfd))) goto end; wasfd->attempt_reads=0; } /* Has to be before the chuser/chgrp stuff to allow clients to switch to different clients when both clients have different user/group settings. */ if(extra_comms(as, &incexc, &srestore, confs, cconfs)) { log_and_send(as->asfd, "running extra comms failed on server"); goto end; } // Needs to happen after extra_comms, in case extra_comms resets them. confs_user=get_string(confs[OPT_USER]); cconfs_user=get_string(cconfs[OPT_USER]); confs_group=get_string(confs[OPT_GROUP]); cconfs_group=get_string(cconfs[OPT_GROUP]); /* Now that the client conf is loaded, we might want to chuser or chgrp. The main process could have already done this, so we don't want to try doing it again if cconfs has the same values, because it will fail. */ if( (!confs_user || (cconfs_user && strcmp(confs_user, cconfs_user))) ||(!confs_group ||(cconfs_group && strcmp(confs_group,cconfs_group)))) { if(chuser_and_or_chgrp(cconfs_user, cconfs_group)) { log_and_send(as->asfd, "chuser_and_or_chgrp failed on server"); goto end; } } if(as->asfd->read(as->asfd)) goto end; // If this is a status server, run the status server. if(is_status_server) { ret=status_server(as, cconfs); goto end; } ret=0; s_script_pre=get_string(cconfs[OPT_S_SCRIPT_PRE]); s_script_post=get_string(cconfs[OPT_S_SCRIPT_POST]); // FIX THIS: Make the script components part of a struct, and just // pass in the correct struct. Same below. if(s_script_pre) ret=run_server_script(as->asfd, "pre", s_script_pre, get_strlist(cconfs[OPT_S_SCRIPT_PRE_ARG]), get_int(cconfs[OPT_S_SCRIPT_PRE_NOTIFY]), cconfs, ret, timer_ret); if(!ret) ret=run_action_server(as, incexc, srestore, &timer_ret, cconfs); if((!ret || get_int(cconfs[OPT_S_SCRIPT_POST_RUN_ON_FAIL])) && s_script_post) ret=run_server_script(as->asfd, "post", s_script_post, get_strlist(cconfs[OPT_S_SCRIPT_POST_ARG]), get_int(cconfs[OPT_S_SCRIPT_POST_NOTIFY]), cconfs, ret, timer_ret); end: return ret; }