Let $y$ be a smooth function $[0,L] \to \mathbb{R}$. I am interested in finding the values of $\alpha\in[0,2\pi)$ such that the solution of the initial value problem $$\tag{1}\label{eq1} \begin{cases} g(t,y,y')=0,\\ y(0)=\alpha \end{cases} $$ is a local extremum of the functional $$J(y) = \int_{0}^{L}F(t,y)\,dt.$$
I thought I could solve this problem using calculus of variations. As far as I understood (and also looking at this question), if $y$ is both a solution of \eqref{eq1} and an extremum of $J$, then there exists a function $\lambda = \lambda(t)$ such that the following equation holds: $$ \frac{\partial F}{\partial y} = \lambda \left(\frac{\partial g}{\partial y} - \frac{d}{dt} \frac{\partial g}{\partial y'}\right). $$ Am I correct?
In particular, in my case the second term inside the parenthesis vanishes, so that I only have $$\tag{2}\label{eq2} \frac{\partial F}{\partial y} = \lambda \frac{\partial g}{\partial y}. $$
Now, I can solve \eqref{eq2} for $y= y(\lambda)$. However, being $\lambda$ a function, substitution of $y(\lambda)$ into \eqref{eq1} gives a new initial value problem (this time in $\lambda$), and so I have not reduced the problem at all.
What am I missing?