Hier habe ich auch noch einen.
Code: Alles auswählen
- -n name special output (e.g. -d Neutrino)
+ -n name special output (e.g. -n Neutrino)
Code: Alles auswählen
- -n name special output (e.g. -d Neutrino)
+ -n name special output (e.g. -n Neutrino)
Code: Alles auswählen
/*
* Tool for printing some image information during bootup.
*
* $Id: cdkVcInfo.cpp,v 1.3 2007/03/31 13:46:24 feynman Exp $, erweitert durch liab
*
* Copyright (C) 2006 the Tuxbox project http://www.tuxbox.org.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
#include <stdio.h>
#include <string>
#define CONSOLE "/dev/vc/0"
#define VERSION_FILE "/.version"
#define VERSION_FILE2 "/proc/version"
#define char_delay_usec 500
#define BUFFERSIZE 255
#define BIGBUFFERSIZE 2000
int main()
{
switch (fork()) {
case -1:
perror("[cdkVcInfo] fork");
return -1;
case 0:
break;
default:
return 0;
}
if (setsid() < 0) {
perror("[cdkVcInfo] setsid");
return 1;
}
char buf[BUFFERSIZE] = "";
int release_type = -1;
int imageversion = 0;
int imagesubver = 0;
int year = 2000;
int month = 01;
int day = 01;
int hour = 00;
int minute = 00;
char creator[32] = "";
char linuxversion[24] = "";
char gccversion[24] = "";
char ersteller[24];
char imagename[9] = "neutrino";
char imgname[13] ="";
char* imagetyp ="squashfs";
char* imgtyp ="";
char root[16] = "Intern";
char adresse[255] = "DHCP";
char broadcast[16] = "";
char gateway[16] = "";
char netmask[16] = "";
char nameserver[16] = "";
FILE* fv0 = fopen(VERSION_FILE, "a"); //Versionsdatei (/.version) beschreibbar, dann jffs2
if (fv0) {
fclose(fv0);
imagetyp = "jffs2";
}
FILE* fn = fopen("/etc/network/interfaces", "r"); //Netzwerkdaten auswerten
if (fn) {
while(fgets(buf, BUFFERSIZE, fn)!=NULL) {
sscanf(buf, " address %s" , (char *) &adresse);
sscanf(buf, " broadcast %s" , (char *) &broadcast);
sscanf(buf, " gateway %s" , (char *) &gateway);
sscanf(buf, " netmask %s" , (char *) &netmask);
}
fclose(fn);
}
FILE* fr = fopen("/etc/resolv.conf", "r"); //Nameserver ermitteln
if (fr) {
while(fgets(buf, BUFFERSIZE, fr)!=NULL) {
sscanf(buf, "nameserver %s" , (char *) &nameserver);
}
fclose(fr);
}
FILE* fv = fopen(VERSION_FILE, "r"); //Versionsdatei (/.version) auswerten
if (fv) {
while (fgets(buf, BUFFERSIZE, fv)) {
sscanf(buf, "version=%1d%1d%2d%4d%2d%2d%2d%2d",
&release_type, &imageversion, &imagesubver,
&year, &month, &day, &hour, &minute);
sscanf(buf, "creator=%[^\n]", (char *) &creator);
sscanf(buf, "imagename=%[^\n]", (char *) &imgname);
}
fclose(fv);
if (imgname[7] == *"y")
{
imgtyp = "-yadd"; //y im Namen, also yadd
FILE* fn1 = fopen("/proc/cmdline", "r"); //Bei yadd die vom Root-Server aufgezwungene IP ermitteln
if (fn1) {
while(fgets(buf, BUFFERSIZE, fn1)!=NULL) {
sscanf(buf, "root=/dev/nfs %s%s%s" , (char *) &adresse, (char *) &adresse, (char *) &adresse);
}
fclose(fn1);
strcpy( adresse, strstr(buf, "ip=") + strlen("ip=") );
std::string a (adresse);
std::string::size_type i = a.find(":"); //Sucht vorwärts ab Index 0
//i ist jetzt der Index in a, wo ":" beginnt
adresse[i]='\0'; //Schneidet ab i die Zeichen ab
}
}
}
FILE* fv2 = fopen(VERSION_FILE2, "r"); //Versionsdatei (/proc/version) auswerten
if (fv2) {
while (fgets(buf, BUFFERSIZE, fv2)!=NULL) {
sscanf(buf, "Linux version %s%s%s%s%s", (char *) &linuxversion, (char *) &ersteller, (char *) &gccversion, (char *) &gccversion, (char *) &gccversion);
}
fclose(fv2);
}
FILE* fv1 = fopen("/proc/mounts", "r"); //Root-Server IP ermitteln, falls yadd
if (fv1) {
while (fgets(buf, BUFFERSIZE, fv1)!=NULL) {
sscanf(buf, "/dev/root / nfs rw,v2,rsize=4096,wsize=4096,hard,udp,nolock,addr= %s", (char *) &root);
}
fclose(fv1);
}
char message[BIGBUFFERSIZE];
strcpy(message, "");
sprintf(message,
"\n\n\n\n\n\n\n\t\t\t-------- Image Info --------\n\n"
"\t\t\t Image Version : %d.%02d\n"
"\t\t\t Image Type : %s\n"
"\t\t\t Image Name : %s-%s%s\n"
"\t\t\t Creation Date : %02d.%02d.%02d\n"
"\t\t\t Creation Time : %02d:%02d\n"
"\t\t\t Creator : %s\n\n"
"\t\t\t Root-Server : %s\n"
"\t\t\t IP-Adresse : %s\n"
"\t\t\t Netzmaske : %s\n"
"\t\t\t Broadcast : %s\n"
"\t\t\t Gateway : %s\n"
"\t\t\t Nameserver : %s\n\n"
"\t\t Linux Version (%s, gcc Version %s\n"
"\t\t Erstellt mit dem Computer %s\n"
"\n\n\t\t\t\tLoading %s\n",
imageversion, imagesubver,
release_type == 0 ? "Release"
: release_type == 1 ? "Snapshot"
: release_type == 2 ? "Internal"
: "Unknown",
imagename, imagetyp, imgtyp, day, month, year, hour, minute,
creator, root, adresse, netmask, broadcast, gateway,
nameserver, linuxversion, gccversion, ersteller, imagename);
//printf("%s", message);
FILE *fb = fopen(CONSOLE, "w" );
if (fb == 0) {
perror("[cdkVcInfo] fopen");
exit(1);
}
for (unsigned int i = 0; i < strlen(message); i++) {
fputc(message[i], fb);
fflush(fb);
usleep(char_delay_usec);
}
fclose(fb);
exit(0);
}
committed:GetAway hat geschrieben:Patch aktualisiert. advanced_cdkVcInfo.diff
Code: Alles auswählen
--- ../cvs/cdk/root/etc/init.d/25cdkVcInfo 2009-11-21 14:35:52.000000000 +0100
+++ ./cdk/root/etc/init.d/25cdkVcInfo 2010-02-02 19:51:56.000000000 +0100
@@ -4,7 +4,7 @@
case $1 in
start)
- [ -e /var/etc/.boot_info ] && /bin/cdkVcInfo
+ [ -e /var/etc/.boot_info ] && /bin/cdkVcInfo -d 500
;;
esac
Code: Alles auswählen
* Tool for printing some image information during bootup.
*
* $Id: cdkVcInfo.cpp,v 1.6 2010/01/31 12:51:05 rhabarber1848 Exp $
*
* cdkVcInfo - d-box2 linux project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#include <stdio.h>
#include <string>
#include <string.h>
#include <stdlib.h>
#define CONSOLE "/dev/vc/0"
#define VERSION_FILE "/.version"
#define VERSION_FILE2 "/proc/version"
#define INTERFACES_FILE "/etc/network/interfaces"
#define NAMENSSERVER_FILE "/etc/resolv.conf"
#define MOUNTS_FILE "/proc/mounts"
#define BUFFERSIZE 255
#define BIGBUFFERSIZE 2000
#define DEFAULT_DELAY 500
#define MAXOSD 2
enum {VERSION, TYPE, DATE, TIME, CREATOR, NAME, WWW, NETW, DHCP, ROOT, IP, NETM, BROAD, GATEWAY, DNS, HEADLINE,
UNKNOWN, ENABLED, DISABLED, INTERN, LINUX, GCC, UPC, LOAD };
char *info[][MAXOSD] = {
{ "Image Version :" , "Image Version :" },
{ "Image Typ :" , "Image Type :" },
{ "Datum :" , "Creation Date :" },
{ "Uhrzeit :" , "Creation Time :" },
{ "Erstellt von :" , "Creator :" },
{ "Image Name :" , "Image Name :" },
{ "Homepage :" , "Homepage :" },
{ "Netzwerk Status :" , "Network State :" },
{ "DHCP Status :" , "DHCP State :" },
{ "Root-Server :" , "Root-Server :" },
{ "IP Adresse :" , "IP Address :" },
{ "Netzmaske :" , "Subnet Mask :" },
{ "Broadcast :" , "Broadcast :" },
{ "Gateway :" , "Gateway :" },
{ "Nameserver :" , "Nameserver :" },
{ "-------- Netzwerkeinstellungen --------" , "---------- Network Settings -----------" },
{ "-- unbekannt --" , "-- unknown --" },
{ "aktiviert" , "enabled" },
{ "deaktiviert" , "disabled" },
{ "intern" , "intern" },
{ "Linux Version" , "Linux Version" },
{ "gcc Version" , "gcc Version" },
{ "Erstellt mit dem Computer" , "Built with the computer" },
{ "Lade" , "Loading" }
};
int main (int argc, char **argv)
{
switch (fork()) {
case -1:
perror("[cdkVcInfo] fork");
return -1;
case 0:
break;
default:
return 0;
}
if (setsid() < 0) {
perror("[cdkVcInfo] setsid");
return 1;
}
unsigned int id = 1;
int opt = -1;
char buf[BUFFERSIZE] = "";
int release_type = -1;
int imageversion = 0;
int imagesubver = 0;
char imagesubver2[BUFFERSIZE] = "0";
int year = 9999;
int month = 99;
int day = 99;
int hour = 99;
int minute = 99;
bool delay = false;
int delay_usec = -1;
int dhcp = 0;
int nic_on = 0;
char* imagetyp = "squashfs";
char linuxversion[24] = "";
char gccversion[24] = "";
char userpc[24];
char ladename[BUFFERSIZE] = "System";
char creator[BUFFERSIZE];
char imagename[BUFFERSIZE];
char homepage[BUFFERSIZE];
char root[BUFFERSIZE];
char address[BUFFERSIZE];
char broadcast[BUFFERSIZE];
char netmask[BUFFERSIZE];
char nameserver[BUFFERSIZE];
char gateway[BUFFERSIZE];
char null[BUFFERSIZE] = "";
char versioninfo[20];
char cvs_revision[] = "$Revision: 1.6 $";
sscanf(cvs_revision, "%*s %s", versioninfo);
while ((opt = getopt(argc, argv, "hgd:n:")) != -1)
{
switch (opt)
{
case 'h':
if (argc < 3)
{
printf("cdkVcInfo - bootinfo on screen, v%s\n", versioninfo);
printf("Usage: cdkVcInfo [-d n] [-g] [-n name] [-h]\n");
printf("\nPossible options:\n");
printf("\t-h\t\tprint this usage information\n");
printf("\t-g\t\tprint bootinfo in german\n");
printf("\t-d n\t\tdelay in microseconds >500 (e.g. -d 2000)\n");
printf("\t-n name\t\tspecial output (e.g. -n Neutrino)\n");
exit(0);
}
break;
case 'g':
id = 0;
break;
case 'd':
delay_usec = atoi(optarg);
if (delay_usec > 0)
{
if (delay_usec < DEFAULT_DELAY)
delay_usec = DEFAULT_DELAY;
delay = true;
}
break;
case 'n':
strcpy(ladename, optarg);
break;
default:
break;
}
}
strcpy(creator, info[UNKNOWN][id]);
strcpy(imagename, info[UNKNOWN][id]);
strcpy(homepage, info[UNKNOWN][id]);
strcpy(root, info[INTERN][id]);
strcpy(address, info[UNKNOWN][id]);
strcpy(broadcast, info[UNKNOWN][id]);
strcpy(netmask, info[UNKNOWN][id]);
strcpy(nameserver, info[UNKNOWN][id]);
strcpy(gateway, info[UNKNOWN][id]);
FILE* fv1 = fopen(VERSION_FILE, "r");
if (fv1)
{
while (fgets(buf, BUFFERSIZE, fv1)) {
sscanf(buf, "version=%1d%1d%1d%1s%4d%2d%2d%2d%2d",
&release_type, &imageversion, &imagesubver, (char *) &imagesubver2,
&year, &month, &day, &hour, &minute);
sscanf(buf, "creator=%[^\n]", (char *) &creator);
sscanf(buf, "imagename=%[^\n]", (char *) &imagename);
sscanf(buf, "homepage=%[^\n]", (char *) &homepage);
}
fclose(fv1);
}
FILE* fv2 = fopen(INTERFACES_FILE, "r");
if (fv2)
{
while (fgets(buf, BUFFERSIZE, fv2)) {
if (nic_on == 0) {
if (sscanf(buf, "auto eth%[0]", (char *) &null)) {
nic_on=1;
}
}
if (sscanf(buf, "iface eth0 inet stati%[c]", (char *) &null)) {
dhcp = 1;
}
else if (sscanf(buf, "iface eth0 inet dhc%[p]", (char *) &null)) {
dhcp = 2;
}
}
fclose(fv2);
}
FILE* fv3 = fopen(NAMENSSERVER_FILE, "r");
if (fv3)
{
while (fgets(buf, BUFFERSIZE, fv3)) {
sscanf(buf, "nameserver %[^\n]", (char *) &nameserver);
}
fclose(fv3);
}
FILE* fv4 = popen("/sbin/ifconfig eth0", "r");
if (fv4)
{
while (fgets(buf, BUFFERSIZE, fv4)) {
sscanf(buf, " inet addr:%s Bcast:%s Mask:%[^\n]", (char *) &address, (char *) &broadcast, (char *) &netmask);
}
fclose(fv4);
}
FILE* fv5 = popen("/sbin/route -n", "r");
if (fv5)
{
fscanf(fv5, "%*[^\n]\n%*[^\n]\n%*[^\n]\n");
while (fgets(buf, BUFFERSIZE, fv5)) {
sscanf(buf, "%s %[0-9.]", (char *) &null, (char *) &gateway);
}
fclose(fv5);
}
FILE* fv6 = fopen(MOUNTS_FILE, "r"); //Root-Server IP ermitteln, falls yadd
if (fv6) {
while (fgets(buf, BUFFERSIZE, fv1)!=NULL) {
sscanf(buf, "/dev/root / nfs rw,v2,rsize=4096,wsize=4096,hard,udp,nolock,addr= %s", (char *) &root);
}
fclose(fv6);
}
FILE* fv7 = fopen(VERSION_FILE2, "r"); //Versionsdatei (/proc/version) auswerten
if (fv7) {
while (fgets(buf, BUFFERSIZE, fv2)!=NULL) {
sscanf(buf, "Linux version %s%s%s%s%s", (char *) &linuxversion, (char *) &userpc, (char *) &gccversion, (char *) &gccversion, (char *) &gccversion);
}
fclose(fv7);
}
FILE* fv8 = fopen(VERSION_FILE, "a"); //Versionsdatei (/.version) beschreibbar, dann jffs2
if (fv8) {
fclose(fv8);
imagetyp = "jffs2";
}
char message2[BUFFERSIZE];
strcpy(message2, "");
if (delay)
sprintf(message2, "%s %s .... ", info[LOAD][id], ladename);
char message[BIGBUFFERSIZE];
strcpy(message, "");
sprintf(message,
"\n\n\n\n"
"\t\t ---------- Image Information ----------\n\n"
"\t\t %s %d.%d.%s\n" //Image Version
"\t\t %s %s\n\n" //Image Typ
"\t\t %s %02d.%02d.%d\n" //Date
"\t\t %s %d:%02d\n" //Time
"\t\t %s %s\n" //Creator
"\t\t %s %s-%s\n" //Image Name
"\t\t %s %s\n\n" //Homepage
"\t\t %s\n\n"
"\t\t %s %s\n" //Network state
"\t\t %s %s\n" //DHCP state
"\t\t %s %s\n" //Root-Server
"\t\t %s %s\n" //IP Adress
"\t\t %s %s\n" //Subnet
"\t\t %s %s\n" //Broadcast
"\t\t %s %s\n" //Gateway
"\t\t %s %s\n\n\n" //Nameserver
"\t\t %s (%s, %s %s\n " //Linux Version, gcc Version
"\t\t %s %s\n\n" //User, PC
"\t\t\t\t%s",
info[VERSION][id], imageversion, imagesubver, imagesubver2,
info[TYPE][id], release_type == 0 ? "Release"
: release_type == 1 ? "Snapshot"
: release_type == 2 ? "Intern"
: info[UNKNOWN][id],
info[DATE][id], day, month, year,
info[TIME][id], hour, minute,
info[CREATOR][id], creator,
info[NAME][id], imagename, imagetyp,
info[WWW][id], homepage,
info[HEADLINE][id],
info[NETW][id], nic_on == 0 ? info[DISABLED][id] : nic_on == 1 ? info[ENABLED][id] : info[UNKNOWN][id],
info[DHCP][id], dhcp == 1 ? info[DISABLED][id] : dhcp == 2 ? info[ENABLED][id] : info[UNKNOWN][id],
info[ROOT][id], root,
info[IP][id], address,
info[NETM][id], netmask,
info[BROAD][id], broadcast,
info[GATEWAY][id], gateway,
info[DNS][id], nameserver,
info[LINUX][id], linuxversion,
info[GCC][id], gccversion,
info[UPC][id], userpc,
message2);
FILE *fb = fopen(CONSOLE, "w");
if (fb == 0) {
perror("[cdkVcInfo] fopen");
exit(1);
}
if (delay)
{
for (unsigned int i = 0; i < strlen(message); i++) {
fputc(message[i], fb);
fflush(fb);
usleep(delay_usec);
}
}
else
{
sprintf(message2, "%s %s .... ", info[LOAD][id], ladename);
for (unsigned int i = 0; i < strlen(message); i++) {
fputc(message[i], fb);
}
for (unsigned int i = 0; i < strlen(message2); i++) {
fputc(message2[i], fb);
fflush(fb);
usleep(20000);
}
}
fclose(fb);
exit(0);
}
Dazu musst du nichts verlinken. Kopiere einfach deine eigene Datei nach /var/etc/init.d und sie wird bevorzugt verwendet.liab hat geschrieben:rhabarber1848 bitte noch die /etc/init.d/25cdkVcInfo nach /var/etc/init.d verschieben und in /etc/init.d entsprechend verlinken, damit die Parameter auch beim squashfs geändert werden können.
Verstehe ich das richtig, meine 25cdkVcInfo nach /var/etc/init.d? Dann nimmt er bei mir trotzdem die von /etc/init.d. Lösche ich die in /etc/init.d, dann läuft nichts.rhabarber1848 hat geschrieben:Dazu musst du nichts verlinken. Kopiere einfach deine eigene Datei nach /var/etc/init.d und sie wird bevorzugt verwendet.
Weil es in /etc/init.d/functions in der Funktion run_initscripts so drin steht.liab hat geschrieben:Warum sollte eine cdkVcInfo in /var/etc/init.d zuerst genommen werden?
Das sind keine Startskripts im eigentlichen Sinne, neutrino und enigmaliab hat geschrieben:Esound, enigma und neutrino sind doch auch im /etc/init.d nach /var/etc/init.d verlinkt.
Code: Alles auswählen
#!/bin/sh
# Tuxbox init script for /bin/cdkVcInfo
case $1 in
start)
[ -e /var/etc/.boot_info ] && /bin/cdkVcInfo -d 100000 -g
i=1
jb=$(ps -A | grep -m1 '/bin/cdkVcInfo' | cut -d "S" -f2)
while [ $i -le 60 ]
do
jb1=$(ps -A | grep -m1 '/bin/cdkVcInfo' | cut -d "S" -f2)
if [ "$jb" != "$jb1" ] ; then
i=61
fi
sleep 1
i=`expr $i + 1`
done
;;
esac
exit 0
nur für das anzeigen einiger infos die neutrino startzeit künstlich verlängern..???liab hat geschrieben:...Als Lösung fällt mir im Moment nur ein, nach dem Start von cdkVcInfo ein sleep (ca. 5 - 10) zu setzen. Bei mir reichen sleep 5, da ich vor neutrino noch ein eigenes Skript starte.
Oder man verzichtet auf delay. Bestlösung wäre, neutrino wartet bevor es stört, dass cdkVcInfo fertig ist. Das ließe sich einfach im Startskript realisieren. So etwa (delay sollte man auf max. 100000 beschränken):
...
steht aber noch unbeantwortet. (Für ein Beispiel um popen zu benutzen, siehe plugins.cpp.)Barf hat geschrieben:Nahe liegend wäre ein usergeschriebenes shellskript (falls vorhanden) auszuführen (popen), und stdout auszugeben.
Code: Alles auswählen
/*
* Tool for printing some image information during bootup.
*
* $Id: cdkVcInfo.cpp,v 1.6 2010/01/31 12:51:05 rhabarber1848 Exp $
*
* cdkVcInfo - d-box2 linux project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#include <stdio.h>
#include <string>
#include <string.h>
#include <stdlib.h>
#define CONSOLE "/dev/vc/0"
#define VERSION_FILE "/.version"
#define VERSION_FILE2 "/proc/version"
#define INTERFACES_FILE "/etc/network/interfaces"
#define NAMENSSERVER_FILE "/etc/resolv.conf"
#define MOUNTS_FILE "/proc/mounts"
#define BUFFERSIZE 255
#define BIGBUFFERSIZE 2000
#define MAXOSD 2
enum {VERSION, TYPE, DATE, TIME, CREATOR, NAME, WWW, NETW, DHCP, ROOT, IP, NETM, BROAD, GATEWAY, DNS, HEADLINE,
UNKNOWN, ENABLED, DISABLED, INTERN, LINUX, GCC, UPC, LOAD };
char *info[][MAXOSD] = {
{ "Image Version :" , "Image Version :" },
{ "Image Typ :" , "Image Type :" },
{ "Datum :" , "Creation Date :" },
{ "Uhrzeit :" , "Creation Time :" },
{ "Erstellt von :" , "Creator :" },
{ "Image Name :" , "Image Name :" },
{ "Homepage :" , "Homepage :" },
{ "Netzwerk Status :" , "Network State :" },
{ "DHCP Status :" , "DHCP State :" },
{ "Root-Server :" , "Root-Server :" },
{ "IP Adresse :" , "IP Address :" },
{ "Netzmaske :" , "Subnet Mask :" },
{ "Broadcast :" , "Broadcast :" },
{ "Gateway :" , "Gateway :" },
{ "Nameserver :" , "Nameserver :" },
{ "-------- Netzwerkeinstellungen --------" , "---------- Network Settings -----------" },
{ "-- unbekannt --" , "-- unknown --" },
{ "aktiviert" , "enabled" },
{ "deaktiviert" , "disabled" },
{ "intern" , "intern" },
{ "Linux Version" , "Linux Version" },
{ "gcc Version" , "gcc Version" },
{ "Erstellt mit dem Computer" , "Built with the computer" },
{ "Lade" , "Loading" }
};
int main (int argc, char **argv)
{
switch (fork()) {
case -1:
perror("[cdkVcInfo] fork");
return -1;
case 0:
break;
default:
return 0;
}
if (setsid() < 0) {
perror("[cdkVcInfo] setsid");
return 1;
}
unsigned int id = 1;
int opt = -2;
char buf[BUFFERSIZE] = "";
int release_type = -1;
int imageversion = 0;
int imagesubver = 0;
char imagesubver2[BUFFERSIZE] = "0";
int year = 9999;
int month = 99;
int day = 99;
int hour = 99;
int minute = 99;
bool delay = false;
int dhcp = 0;
int nic_on = 0;
char* imagetyp = "squashfs";
char linuxversion[24] = "";
char gccversion[24] = "";
char userpc[24];
char ladename[BUFFERSIZE] = "System";
char creator[BUFFERSIZE];
char imagename[BUFFERSIZE];
char homepage[BUFFERSIZE];
char root[BUFFERSIZE];
char address[BUFFERSIZE];
char broadcast[BUFFERSIZE];
char netmask[BUFFERSIZE];
char nameserver[BUFFERSIZE];
char gateway[BUFFERSIZE];
char null[BUFFERSIZE] = "";
char versioninfo[20];
char cvs_revision[] = "$Revision: 1.6 $";
sscanf(cvs_revision, "%*s %s", versioninfo);
while ((opt = getopt(argc, argv, "hgdn:")) != -1)
{
switch (opt)
{
case 'h':
if (argc < 3)
{
printf("cdkVcInfo - bootinfo on screen, v%s\n", versioninfo);
printf("Usage: cdkVcInfo [-d] [-g] [-n name] [-h]\n");
printf("\nPossible options:\n");
printf("\t-h\t\tprint this usage information\n");
printf("\t-g\t\tprint bootinfo in german\n");
printf("\t-d\t\tdelay on\n");
printf("\t-n name\t\tspecial output (e.g. -n Neutrino)\n");
exit(0);
}
break;
case 'g':
id = 0;
break;
case 'd':
delay = true;
break;
case 'n':
strcpy(ladename, optarg);
break;
default:
break;
}
}
strcpy(creator, info[UNKNOWN][id]);
strcpy(imagename, info[UNKNOWN][id]);
strcpy(homepage, info[UNKNOWN][id]);
strcpy(root, info[INTERN][id]);
strcpy(address, info[UNKNOWN][id]);
strcpy(broadcast, info[UNKNOWN][id]);
strcpy(netmask, info[UNKNOWN][id]);
strcpy(nameserver, info[UNKNOWN][id]);
strcpy(gateway, info[UNKNOWN][id]);
FILE* fv1 = fopen(VERSION_FILE, "r");
if (fv1)
{
while (fgets(buf, BUFFERSIZE, fv1)) {
sscanf(buf, "version=%1d%1d%1d%1s%4d%2d%2d%2d%2d",
&release_type, &imageversion, &imagesubver, (char *) &imagesubver2,
&year, &month, &day, &hour, &minute);
sscanf(buf, "creator=%[^\n]", (char *) &creator);
sscanf(buf, "imagename=%[^\n]", (char *) &imagename);
sscanf(buf, "homepage=%[^\n]", (char *) &homepage);
}
fclose(fv1);
}
FILE* fv2 = fopen(INTERFACES_FILE, "r");
if (fv2)
{
while (fgets(buf, BUFFERSIZE, fv2)) {
if (nic_on == 0) {
if (sscanf(buf, "auto eth%[0]", (char *) &null)) {
nic_on=1;
}
}
if (sscanf(buf, "iface eth0 inet stati%[c]", (char *) &null)) {
dhcp = 1;
}
else if (sscanf(buf, "iface eth0 inet dhc%[p]", (char *) &null)) {
dhcp = 2;
}
}
fclose(fv2);
}
FILE* fv3 = fopen(NAMENSSERVER_FILE, "r");
if (fv3)
{
while (fgets(buf, BUFFERSIZE, fv3)) {
sscanf(buf, "nameserver %[^\n]", (char *) &nameserver);
}
fclose(fv3);
}
FILE* fv4 = popen("/sbin/ifconfig eth0", "r");
if (fv4)
{
while (fgets(buf, BUFFERSIZE, fv4)) {
sscanf(buf, " inet addr:%s Bcast:%s Mask:%[^\n]", (char *) &address, (char *) &broadcast, (char *) &netmask);
}
fclose(fv4);
}
FILE* fv5 = popen("/sbin/route -n", "r");
if (fv5)
{
fscanf(fv5, "%*[^\n]\n%*[^\n]\n%*[^\n]\n");
while (fgets(buf, BUFFERSIZE, fv5)) {
sscanf(buf, "%s %[0-9.]", (char *) &null, (char *) &gateway);
}
fclose(fv5);
}
FILE* fv6 = fopen(MOUNTS_FILE, "r"); //Root-Server IP ermitteln, falls yadd
if (fv6) {
while (fgets(buf, BUFFERSIZE, fv1)!=NULL) {
sscanf(buf, "/dev/root / nfs rw,v2,rsize=4096,wsize=4096,hard,udp,nolock,addr= %s", (char *) &root);
}
fclose(fv6);
}
FILE* fv7 = fopen(VERSION_FILE2, "r"); //Versionsdatei (/proc/version) auswerten
if (fv7) {
while (fgets(buf, BUFFERSIZE, fv2)!=NULL) {
sscanf(buf, "Linux version %s%s%s%s%s", (char *) &linuxversion, (char *) &userpc, (char *) &gccversion, (char *) &gccversion, (char *) &gccversion);
}
fclose(fv7);
}
FILE* fv8 = fopen(VERSION_FILE, "a"); //Versionsdatei (/.version) beschreibbar, dann jffs2
if (fv8) {
fclose(fv8);
imagetyp = "jffs2";
}
char message2[BUFFERSIZE];
strcpy(message2, "");
if (delay)
sprintf(message2, "%s %s .... ", info[LOAD][id], ladename);
char message[BIGBUFFERSIZE];
strcpy(message, "");
sprintf(message,
"\n\n\n\n"
"\t\t ---------- Image Information ----------\n\n"
"\t\t %s %d.%d.%s\n" //Image Version
"\t\t %s %s\n\n" //Image Typ
"\t\t %s %02d.%02d.%d\n" //Date
"\t\t %s %d:%02d\n" //Time
"\t\t %s %s\n" //Creator
"\t\t %s %s-%s\n" //Image Name
"\t\t %s %s\n\n" //Homepage
"\t\t %s\n\n"
"\t\t %s %s\n" //Network state
"\t\t %s %s\n" //DHCP state
"\t\t %s %s\n" //Root-Server
"\t\t %s %s\n" //IP Adress
"\t\t %s %s\n" //Subnet
"\t\t %s %s\n" //Broadcast
"\t\t %s %s\n" //Gateway
"\t\t %s %s\n\n\n" //Nameserver
"\t\t %s (%s, %s %s\n " //Linux Version, gcc Version
"\t\t %s %s\n\n" //User, PC
"\t\t\t\t%s",
info[VERSION][id], imageversion, imagesubver, imagesubver2,
info[TYPE][id], release_type == 0 ? "Release"
: release_type == 1 ? "Snapshot"
: release_type == 2 ? "Intern"
: info[UNKNOWN][id],
info[DATE][id], day, month, year,
info[TIME][id], hour, minute,
info[CREATOR][id], creator,
info[NAME][id], imagename, imagetyp,
info[WWW][id], homepage,
info[HEADLINE][id],
info[NETW][id], nic_on == 0 ? info[DISABLED][id] : nic_on == 1 ? info[ENABLED][id] : info[UNKNOWN][id],
info[DHCP][id], dhcp == 1 ? info[DISABLED][id] : dhcp == 2 ? info[ENABLED][id] : info[UNKNOWN][id],
info[ROOT][id], root,
info[IP][id], address,
info[NETM][id], netmask,
info[BROAD][id], broadcast,
info[GATEWAY][id], gateway,
info[DNS][id], nameserver,
info[LINUX][id], linuxversion,
info[GCC][id], gccversion,
info[UPC][id], userpc,
message2);
FILE *fb = fopen(CONSOLE, "w");
if (fb == 0) {
perror("[cdkVcInfo] fopen");
exit(1);
}
if (delay)
{
for (unsigned int i = 0; i < strlen(message); i++) {
fputc(message[i], fb);
fflush(fb);
}
}
else
{
sprintf(message2, "%s %s .... ", info[LOAD][id], ladename);
for (unsigned int i = 0; i < strlen(message); i++) {
fputc(message[i], fb);
}
for (unsigned int i = 0; i < strlen(message2); i++) {
fputc(message2[i], fb);
fflush(fb);
usleep(20000);
}
}
fclose(fb);
exit(0);
}
Für alle init-Skripts werden automatisch die S- und K-Links angelegt,liab hat geschrieben:Warum eigentlich die K25cdkVcInfo?
Kleiner Tipp: Das Wiki ist für alle da, die sinnvolles Wissen über die Materie haben und mitteilen wollen, also wenn man etwas sieht, was unvollständig, falsch oder überarbeitungswürdig usw. ist, nicht unnötig drüber reden, sondern einfach selbst mal ändern. dazu muss man (meistens) noch nicht mal im Wiki registriert sein.liab hat geschrieben:
Vielleicht noch hinter Stop (Kill) eintragen, das macht das K nachvollziehbar und prägt sich ein.