Subversion Repositories DevTools

Rev

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

Rev 6535 Rev 6547
Line 1992... Line 1992...
1992
#                       --NoCopy        - Don't copy the script, just add links
1992
#                       --NoCopy        - Don't copy the script, just add links
1993
#                       --Afc           - Place in AFC init area
1993
#                       --Afc           - Place in AFC init area
1994
#                       --FromPackage   - Source is in a package
1994
#                       --FromPackage   - Source is in a package
1995
#                       --Hibernate     - Add hibernate symlink
1995
#                       --Hibernate     - Add hibernate symlink
1996
#                       --Resume        - Add resume symlink
1996
#                       --Resume        - Add resume symlink
-
 
1997
#                       --Sk100Mode     - Force SK100 Mode
1997
#
1998
#
1998
# Returns         : 
1999
# Returns         : 
1999
#
2000
#
2000
sub AddInitScript
2001
sub AddInitScript
2001
{
2002
{
Line 2003... Line 2004...
2003
    my $basedir = "";
2004
    my $basedir = "";
2004
    my @args;
2005
    my @args;
2005
    my $from_package = 0;
2006
    my $from_package = 0;
2006
    my $hibernate = 0;
2007
    my $hibernate = 0;
2007
    my $resume = 0;
2008
    my $resume = 0;
-
 
2009
    my $sk100 = ($opt_platform eq 'SK100');
-
 
2010
    my $afcMode;
-
 
2011
 
2008
    return 1 unless ($ActiveSection);
2012
    return 1 unless ($ActiveSection);
2009
 
2013
 
2010
    # This directive is only available on the VIX platforms
2014
    # This directive is only available on the VIX platforms
2011
    #   Kludgey test - at the moment
2015
    #   Kludgey test - at the moment
2012
    #
2016
    #
2013
    if ($opt_pkgarch =~ m~i386~)
2017
    if ($opt_pkgarch =~ m~i386~) {
2014
    {
-
 
2015
        Error ("AddInitScript is not supported on this platform"); 
2018
        Error ("AddInitScript is not supported on this platform"); 
2016
    }
2019
    }
2017
 
2020
 
2018
    #
2021
    #
2019
    #   Process and Remove options
2022
    #   Process and Remove options
Line 2023... Line 2026...
2023
        if ( m/^--NoCopy/ ) {
2026
        if ( m/^--NoCopy/ ) {
2024
            $no_copy = 1;
2027
            $no_copy = 1;
2025
 
2028
 
2026
        } elsif ( m/^--Afc/ ) {
2029
        } elsif ( m/^--Afc/ ) {
2027
            $basedir = "/afc";
2030
            $basedir = "/afc";
-
 
2031
            $afcMode = 1;
2028
 
2032
 
2029
        } elsif ( m/^--FromPackage/ ) {
2033
        } elsif ( m/^--FromPackage/ ) {
2030
            $from_package = 1;
2034
            $from_package = 1;
2031
 
2035
 
2032
        } elsif ( m/^--Hibernate=(.*)/ ) {
2036
        } elsif ( m/^--Hibernate=(.*)/ ) {
2033
            $hibernate = $1;
2037
            $hibernate = $1;
2034
 
2038
 
2035
        } elsif ( m/^--Resume=(.*)/ ) {
2039
        } elsif ( m/^--Resume=(.*)/ ) {
2036
            $resume = $1;
2040
            $resume = $1;
2037
 
2041
 
-
 
2042
        } elsif ( m/^--SK100/i ) {
-
 
2043
            $sk100 = 1;
-
 
2044
 
-
 
2045
        } elsif ( m/^--NoSK100/i ) {
-
 
2046
            $sk100 = 0;
-
 
2047
 
2038
        } elsif ( m/^--/ ) {
2048
        } elsif ( m/^--/ ) {
2039
            Error ("AddInitScript: Unknown option: $_");
2049
            Error ("AddInitScript: Unknown option: $_");
2040
 
2050
 
2041
        } else {
2051
        } else {
2042
            push @args, $_;
2052
            push @args, $_;
Line 2046... Line 2056...
2046
 
2056
 
2047
    my( $script, $start, $stop ) = @args;
2057
    my( $script, $start, $stop ) = @args;
2048
    Error ("No script file specified") unless ( $script );
2058
    Error ("No script file specified") unless ( $script );
2049
    Warning("AddInitScript: No start or stop index specified") unless ( $start || $stop );
2059
    Warning("AddInitScript: No start or stop index specified") unless ( $start || $stop );
2050
    Verbose ("AddInitScript: $script, " . ($start || 'No Start') . ", " . ($stop || 'No Stop'));
2060
    Verbose ("AddInitScript: $script, " . ($start || 'No Start') . ", " . ($stop || 'No Stop'));
-
 
2061
    Error ("Resume script not supported") if ($resume && !$sk100);
-
 
2062
    Error ("Hibernate script not supported") if ($hibernate && !$sk100);
-
 
2063
    Error ("AFC mode not supported on SK100 (@args)") if ( $sk100 && $afcMode );
2051
    $script = ResolveFile($from_package, $script );
2064
    $script = ResolveFile($from_package, $script );
2052
    Message ("basedir: $basedir");
-
 
2053
    my $tdir = $basedir . "/etc/init.d/init.d";
-
 
2054
    if ( $opt_platform eq 'SK100' ) {
-
 
2055
        $tdir = $basedir . "/etc/init.d/init.vix.d";
-
 
2056
    }
-
 
2057
    my $base = StripDir($script);
-
 
2058
 
2065
 
-
 
2066
    my $tdir = $sk100 ?  "/etc/init.d/init.vix.d" : "/etc/init.d/init.d";
-
 
2067
    $tdir = catdir($basedir, $tdir);
-
 
2068
    my $base = StripDir($script);
2059
    CopyFile( $script, $tdir ) unless $no_copy;
2069
    CopyFile( $script, $tdir ) unless $no_copy;
2060
 
2070
 
2061
    my $link;
2071
    my $link;
2062
    my $linkPath = "/etc/init.d/";
2072
    my $linkPath = $sk100 ? "/etc/init.d/init.vix.d/" : "/etc/init.d/";
2063
    if ( $opt_platform eq 'SK100' ) {
2073
    $linkPath = catdir($basedir, $linkPath) . '/';
2064
        $linkPath = $basedir . "/etc/init.d/init.vix.d/";
2074
    Verbose("InitScript: ", $base, $tdir, $linkPath);
2065
    }
2075
 
2066
    if ( $start ) {
2076
    if ( $start ) {
2067
        $link = sprintf ("${linkPath}S%2.2d%s", $start, $base );
2077
        $link = sprintf ("${linkPath}S%2.2d%s", $start, $base );
2068
        MakeSymLink( "$tdir/$base", $link);
2078
        MakeSymLink( "$tdir/$base", $link);
2069
    }
2079
    }
2070
 
2080
 
Line 2081... Line 2091...
2081
    if ( $resume ) {
2091
    if ( $resume ) {
2082
        $link = sprintf ("${linkPath}R%2.2d%s", $resume, $base );
2092
        $link = sprintf ("${linkPath}R%2.2d%s", $resume, $base );
2083
        MakeSymLink( "$tdir/$base", $link);
2093
        MakeSymLink( "$tdir/$base", $link);
2084
    }
2094
    }
2085
 
2095
 
-
 
2096
    # In SK100 mode
2086
    # on SK100 init script must be placed in rc.local.d and mus be sources and 
2097
    #   init script must be placed in rc.local.d and must be sources and 
2087
    # a start stop resume or suspend function must be implemented.
2098
    #   a start stop resume or suspend function must be implemented.
2088
    # For VIX these functions will call existing initscripts already package in
2099
    # For VIX these functions will call existing initscripts already package in
2089
    # a vix folder. 
2100
    # a vix folder. 
2090
    if ( $opt_platform eq 'SK100' ) {
2101
    if ( $sk100 ) {
-
 
2102
 
-
 
2103
        my $rcLocal =  "/etc/init.d/rc.local.d";
2091
        my $service_file = "$base" . ".service";
2104
        my $rcLocalFile = catfile( $rcLocal, $base);
-
 
2105
        my $rcWorkFile = catfile($WorkDir, $rcLocalFile );
-
 
2106
        my $fh;
-
 
2107
        CreateDir($rcLocal);
-
 
2108
 
2092
        Message ("creating service file for SK100: $service_file in $basedir");
2109
        Message ("creating service file: $rcLocalFile");
2093
        unless (open FILE,'>'.$service_file) {
2110
        unless (open $fh,'>', $rcWorkFile) {
2094
            Error ("Failed to create Service file for SK100");
2111
            Error ("Failed to create Service file in $rcLocal, $!");
2095
        }
2112
        }
2096
        print FILE "#!/bin/sh\\n\\n# $base service file\n\n";
2113
        print $fh "#!/bin/sh\n# $base service file\n\n";
2097
        print FILE "start() {\n    [ -e /etc/init.d/init.vix.d/$base ] && /etc/init.d/init.vix.d/$base start\n}\n";
2114
        print $fh "start() {\n    [ -e /etc/init.d/init.vix.d/$base ] && /etc/init.d/init.vix.d/$base start\n}\n";
2098
        print FILE "stop() {\n    [ -e /etc/init.d/init.vix.d/$base ] && /etc/init.d/init.vix.d/$base stop\n}\n";
2115
        print $fh "stop() {\n    [ -e /etc/init.d/init.vix.d/$base ] && /etc/init.d/init.vix.d/$base stop\n}\n";
2099
        print FILE "restart() {\n    [ -e /etc/init.d/init.vix.d/$base ] && /etc/init.d/init.vix.d/$base restart\n}\n";
2116
        print $fh "restart() {\n    [ -e /etc/init.d/init.vix.d/$base ] && /etc/init.d/init.vix.d/$base restart\n}\n";
2100
        print FILE "suspend() {\n    [ -e /etc/init.d/init.vix.d/$base ] && /etc/init.d/init.vix.d/$base suspend\n}\n";
2117
        print $fh "suspend() {\n    [ -e /etc/init.d/init.vix.d/$base ] && /etc/init.d/init.vix.d/$base suspend\n}\n";
2101
        print FILE "resume() {\n    [ -e /etc/init.d/init.vix.d/$base ] && /etc/init.d/init.vix.d/$base resume\n}\n";
2118
        print $fh "resume() {\n    [ -e /etc/init.d/init.vix.d/$base ] && /etc/init.d/init.vix.d/$base resume\n}\n";
2102
        close FILE;
2119
        close $fh;
2103
        CopyFile($service_file, "/etc/init.d/rc.local.d", "$base");
-
 
2104
        SetFilePerms('a+rx', "/etc/init.d/rc.local.d/$base");
2120
        SetFilePerms('a+rx', "/etc/init.d/rc.local.d/$base");
2105
    }
2121
    }
-
 
2122
 
-
 
2123
    return 1;
2106
}
2124
}
2107
 
2125
 
2108
#-------------------------------------------------------------------------------
2126
#-------------------------------------------------------------------------------
2109
# Function        : CatFile
2127
# Function        : CatFile
2110
#
2128
#