X-Recipient: archive-cygwin@delorie.com
X-Original-To: cygwin@cygwin.com
Delivered-To: cygwin@cygwin.com
DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2162D3858D35
Authentication-Results: sourceware.org; dmarc=none (p=none dis=none)
 header.from=SystematicSw.ab.ca
Authentication-Results: sourceware.org;
 spf=none smtp.mailfrom=systematicsw.ab.ca
X-Authority-Analysis: v=2.4 cv=S9vKfagP c=1 sm=1 tr=0 ts=61f1adbc
 a=T+ovY1NZ+FAi/xYICV7Bgg==:117 a=T+ovY1NZ+FAi/xYICV7Bgg==:17
 a=IkcTkHD0fZMA:10 a=94nOnFI1EgyDtX4ev68A:9 a=QEXdDO2ut3YA:10
Message-ID: <b3264a97-b67c-b1dd-c9b3-ad6cdf674862@SystematicSw.ab.ca>
Date: Wed, 26 Jan 2022 13:23:24 -0700
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
 Thunderbird/91.5.0
Subject: Re: services startup postinstall scripts
Content-Language: en-CA
To: cygwin@cygwin.com
References: <CAFWoy7ELn=KACzSEkBRBiapPJw_Ka-A3hx0LvOH3GPwPiNsM=A@mail.gmail.com>
 <SJ0PR09MB71022762C47F7DBD561593B1A55A9@SJ0PR09MB7102.namprd09.prod.outlook.com>
 <CAFWoy7EJ3tkc2F9h74_hny0Fu5Jf5qLeca1pFdSUaxX7YjTLmg@mail.gmail.com>
 <SJ0PR09MB71023C5EF158E30414727266A55A9@SJ0PR09MB7102.namprd09.prod.outlook.com>
 <59cdd990-5b36-7cc8-8d97-4f3c1f042535@SystematicSw.ab.ca>
 <118552712.20220126175029@yandex.ru>
From: Brian Inglis <Brian.Inglis@SystematicSw.ab.ca>
Organization: Systematic Software
In-Reply-To: <118552712.20220126175029@yandex.ru>
X-CMAE-Envelope: MS4xfOfe0sRz5B8O10bFPGcW1f/kYNR7bO5d/OLUKWx8Ck4rSQtHhCsz4cHfXFFTT6zgC6IODUMCRi87P/WEd6UQ46e5nJtfKKfWXuMbgakSJVGQBdyqUpK9
 z4ZdV/XsceOD3+EVs/gpOLavohmXGB8TdeEFxn8nOrPXVwNQ7LaS1nY70EaKvgecRDN76cCEfV8RDtCEKySqfMiyov0M8XR3aLo=
X-Spam-Status: No, score=-1160.7 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS,
 KAM_LAZY_DOMAIN_SECURITY, NICE_REPLY_A, RCVD_IN_BARRACUDACENTRAL,
 RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE,
 TXREP autolearn=no autolearn_force=no version=3.4.4
X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on
 server2.sourceware.org
X-BeenThere: cygwin@cygwin.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Unsubscribe: <https://cygwin.com/mailman/options/cygwin>,
 <mailto:cygwin-request@cygwin.com?subject=unsubscribe>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-request@cygwin.com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
 <mailto:cygwin-request@cygwin.com?subject=subscribe>
Reply-To: cygwin@cygwin.com
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset="us-ascii"; Format="flowed"
Errors-To: cygwin-bounces+archive-cygwin=delorie.com@cygwin.com
Sender: "Cygwin" <cygwin-bounces+archive-cygwin=delorie.com@cygwin.com>

On 2022-01-26 07:50, Andrey Repin wrote:
> Greetings, Brian Inglis!
> 
>> restart them in a late local permanent postinstall script
>> /etc/postinstall/zp_z0_l_start_services.dash after setup.
> 
> It never occured to me that I can use postinstall tasks to restart services :D
> 
> Just add a line
> 
> for svc in cygserver $( cygrunsrv --list | grep -v cygserver ); do net start "$svc"; done
> 
> and you're golden!

To avoid conflicts you may first want to stop some Windows services 
using first sc, then net as backup:

for srv in	ssh ssh-agent sshbroker sshproxy	\
		sshd sshdbroker sshdproxy		\
		vmictimesysnc w32time # for GPS ref Windows NTP server
do
	sc stop		$srv
	sleep 1
	net stop	$srv
done

then start all Cygwin services using cygrunsrv, then sc, then net to be 
more sure:

for srv in $(cygrunsrv -L)
do
	cygrunsrv -S	$srv
	sleep 1
	sc start	$srv
	sleep 1
	net start	$srv
done

with suitable checks, messages, and logging added.

-- 
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

This email may be disturbing to some readers as it contains
too much technical detail. Reader discretion is advised.
[Data in binary units and prefixes, physical quantities in SI.]

-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple
