Subversion Repositories DevTools

Rev

Rev 6490 | Rev 6515 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6490 Rev 6491
Line 1975... Line 1975...
1975
#                   $stop       - Stop Number
1975
#                   $stop       - Stop Number
1976
#                   Options:
1976
#                   Options:
1977
#                       --NoCopy        - Don't copy the script, just add links
1977
#                       --NoCopy        - Don't copy the script, just add links
1978
#                       --Afc           - Place in AFC init area
1978
#                       --Afc           - Place in AFC init area
1979
#                       --FromPackage   - Source is in a package
1979
#                       --FromPackage   - Source is in a package
-
 
1980
#                       --Hibernate     - Add hibernate symlink
-
 
1981
#                       --Resume        - Add resume symlink
1980
#
1982
#
1981
# Returns         : 
1983
# Returns         : 
1982
#
1984
#
1983
sub AddInitScript
1985
sub AddInitScript
1984
{
1986
{
1985
    my $no_copy;
1987
    my $no_copy;
1986
    my $basedir = "";
1988
    my $basedir = "";
1987
    my @args;
1989
    my @args;
1988
    my $from_package = 0;
1990
    my $from_package = 0;
-
 
1991
    my $hibernate = 0;
-
 
1992
    my $resume = 0;
1989
    return 1 unless ($ActiveSection);
1993
    return 1 unless ($ActiveSection);
1990
 
1994
 
1991
    # This directive is only available on the VIX platforms
1995
    # This directive is only available on the VIX platforms
1992
    #   Kludgey test - at the moment
1996
    #   Kludgey test - at the moment
1993
    #
1997
    #
Line 2008... Line 2012...
2008
            $basedir = "/afc";
2012
            $basedir = "/afc";
2009
 
2013
 
2010
        } elsif ( m/^--FromPackage/ ) {
2014
        } elsif ( m/^--FromPackage/ ) {
2011
            $from_package = 1;
2015
            $from_package = 1;
2012
 
2016
 
-
 
2017
        } elsif ( m/^--Hibernate=(.*)/ ) {
-
 
2018
            $hibernate = $1;
-
 
2019
 
-
 
2020
        } elsif ( m/^--Resume=(.*)/ ) {
-
 
2021
            $resume = $1;
-
 
2022
 
2013
        } elsif ( m/^--/ ) {
2023
        } elsif ( m/^--/ ) {
2014
            Error ("AddInitScript: Unknown option: $_");
2024
            Error ("AddInitScript: Unknown option: $_");
2015
 
2025
 
2016
        } else {
2026
        } else {
2017
            push @args, $_;
2027
            push @args, $_;
Line 2022... Line 2032...
2022
    my( $script, $start, $stop ) = @args;
2032
    my( $script, $start, $stop ) = @args;
2023
    Error ("No script file specified") unless ( $script );
2033
    Error ("No script file specified") unless ( $script );
2024
    Warning("AddInitScript: No start or stop index specified") unless ( $start || $stop );
2034
    Warning("AddInitScript: No start or stop index specified") unless ( $start || $stop );
2025
    Verbose ("AddInitScript: $script, " . ($start || 'No Start') . ", " . ($stop || 'No Stop'));
2035
    Verbose ("AddInitScript: $script, " . ($start || 'No Start') . ", " . ($stop || 'No Stop'));
2026
    $script = ResolveFile($from_package, $script );
2036
    $script = ResolveFile($from_package, $script );
2027
 
-
 
-
 
2037
    Message ("basedir: $basedir");
2028
    my $tdir = $basedir . "/etc/init.d/init.d";
2038
    my $tdir = $basedir . "/etc/init.d/init.d";
-
 
2039
    if ( $opt_platform eq 'SK100' ) {
-
 
2040
        $tdir = $basedir . "/etc/init.d/init.vix.d/";
-
 
2041
    }
2029
    my $base = StripDir($script);
2042
    my $base = StripDir($script);
2030
 
2043
 
2031
    CopyFile( $script, $tdir ) unless $no_copy;
2044
    CopyFile( $script, $tdir ) unless $no_copy;
2032
 
2045
 
2033
    my $link;
2046
    my $link;
-
 
2047
    my $linkPath = "/etc/init.d/";
2034
    if ( $start )
2048
    if ( $opt_platform eq 'SK100' ) {
-
 
2049
        $linkPath = $basedir . "/etc/init.d/init.vix.d/";
2035
    {
2050
    }
-
 
2051
    if ( $start ) {
2036
        $link = sprintf ("${basedir}/etc/init.d/S%2.2d%s", $start, $base );
2052
        $link = sprintf ("${linkPath}S%2.2d%s", $start, $base );
2037
        MakeSymLink( "$tdir/$base", $link);
2053
        MakeSymLink( "$tdir/$base", $link);
2038
    }
2054
    }
2039
 
2055
 
2040
    if ( $stop )
2056
    if ( $stop ) {
-
 
2057
        $link = sprintf ("${linkPath}K%2.2d%s", $stop, $base );
-
 
2058
        MakeSymLink( "$tdir/$base", $link);
-
 
2059
    }
-
 
2060
 
-
 
2061
    if ( $hibernate ) {
-
 
2062
        $link = sprintf ("${linkPath}H%2.2d%s", $hibernate, $base );
-
 
2063
        MakeSymLink( "$tdir/$base", $link);
2041
    {
2064
    }
-
 
2065
 
-
 
2066
    if ( $resume ) {
2042
        $link = sprintf ("${basedir}/etc/init.d/K%2.2d%s", $stop, $base );
2067
        $link = sprintf ("${linkPath}R%2.2d%s", $resume, $base );
2043
        MakeSymLink( "$tdir/$base", $link);
2068
        MakeSymLink( "$tdir/$base", $link);
2044
    }
2069
    }
-
 
2070
 
-
 
2071
    # on SK100 init script must be placed in rc.local.d and mus be sources and 
-
 
2072
    # a start stop resume or suspend function must be implemented.
-
 
2073
    # For VIX these functions will call existing initscripts already package in
-
 
2074
    # a vix folder. 
-
 
2075
    if ( $opt_platform eq 'SK100' ) {
-
 
2076
        my $service_file = "$base" . ".service";
-
 
2077
        Message ("creating service file for SK100: $service_file in $basedir");
-
 
2078
        unless (open FILE,'>'.$service_file) {
-
 
2079
            Error ("Failed to create Service file for SK100");
-
 
2080
        }
-
 
2081
        
-
 
2082
        print FILE "#!/bin/sh\\n\\n# $base service file\n\n";
-
 
2083
        print FILE "start() {\n    [ -e /etc/init.d/init.vix.d/$base ] && /etc/init.d/init.vix.d/$base start\n}\n";
-
 
2084
        print FILE "stop() {\n    [ -e /etc/init.d/init.vix.d/$base ] && /etc/init.d/init.vix.d/$base stop\n}\n";
-
 
2085
        print FILE "restart() {\n    [ -e /etc/init.d/init.vix.d/$base ] && /etc/init.d/init.vix.d/$base restart\n}\n";
-
 
2086
        print FILE "suspend() {\n    [ -e /etc/init.d/init.vix.d/$base ] && /etc/init.d/init.vix.d/$base suspend\n}\n";
-
 
2087
        print FILE "resume() {\n    [ -e /etc/init.d/init.vix.d/$base ] && /etc/init.d/init.vix.d/$base resume\n}\n";
-
 
2088
        close FILE;
-
 
2089
        CopyFile($service_file, "/etc/init.d/rc.local.d", "$base");
-
 
2090
    }
2045
}
2091
}
2046
 
2092
 
2047
#-------------------------------------------------------------------------------
2093
#-------------------------------------------------------------------------------
2048
# Function        : CatFile
2094
# Function        : CatFile
2049
#
2095
#