Deuteronomy 20:2-12

2 And when you are on the point of attacking, let the priest come forward and say to the people,
3 Give ear, O Israel: today you are going forward to the fight; let your heart be strong; do not let uncontrolled fear overcome you because of those who are against you;
4 For the Lord your God goes with you, fighting for you to give you salvation from those who are against you.
5 And let the overseers say to the people, If there is any man who has made for himself a new house and has not gone into it, let him go back to his house, so that in the event of his death in the fight, another may not take his house for himself.
6 Or if any man has made a vine-garden without taking the first-fruits of it, let him go back to his house, so that in the event of his death in the fight, another may not be the first to make use of the fruit.
7 Or if any man is newly married and has had no sex relations with his wife, let him go back to his house, so that in the event of his death in the fight, another man may not take her.
8 And let the overseers go on to say to the people, If there is any man whose heart is feeble with fear, let him go back to his house before he makes the hearts of his countrymen feeble.
9 Then, after saying these words to the people, let the overseers put captains over the army.
10 When you come to a town, before attacking it, make an offer of peace.
11 And if it gives you back an answer of peace, opening its doors to you, then all the people in it may be put to forced work as your servants.
12 If however it will not make peace with you, but war, then let it be shut in on all sides: