[ { "taaknaam": "00. Presentatie Django", "taaktext": "
Django is een professioneel raamwerk om internet applicaties mee te bouwen.
\r\nZeker bij complexe applicaties zorgt Django er voor dat het relatief eenvoudig is om snel met resultaten te komen.
\r\nHet mooie is dat belangrijke basisfunctionaliteiten zoals bijvoorbeeld inloggen en registreren al in een app zitten en het eenvoudig wordt om uit te breiden naar uw wensen.
Django of Laravel: Welk framework is het beste in 2022 ? zie https://kinsta.com/nl/blog/django-of-laravel/#django-en-laravel-welk-framework-is-beter-voor-webdevelopment
\r\n\r\nDjango heeft het MVT design structuur ! zie https://www.geeksforgeeks.org/django-project-mvt-structure/
\r\n\r\n2005 : World Online (krant VS) ontwikkelaars Adrian Holovaty en Willison Simon samen met ,Jacob Kaplan-Mosse, Wilson Miner
\r\nPHP gedumpt en Python werd gebruikt voor ontwikkelen van websites ; succes met Lawrence.com
\r\nopen-source software Django genoemd naar Django Reinhardt (in België geboren als Jean Reinhardt 1910-1953 een gipsy jazz muzikant) daar Adrian Holovaty een Am muzikant van jazz , woont nu in Amsterdam...
sedert 1,5 jaar enorm succes ... , nu al aan versie 3.0 (april 3.1, dec 3.2 en eind 2021 4.0)
\r\nMVC raamwerk
\r\nMVC (Model-View-Controller)
\r\nWat is MVC?
\r\nMVC is een software-architectuur ontwerppatroon . Het verdeelt of scheidt uw app in drie delen:
\r\nModel: verantwoordelijk voor gegevensopslag en -beheer,
\r\nView = weergave: verantwoordelijk voor het weergeven en weergeven van de gebruikersinterface
\r\nController: verantwoordelijk voor de afhandeling van logica om de gebruikersinterface te besturen en met het datamodel te werken.
MVT structuur:
\r\n\r\n
\r\nmodel : waar we onze gegevens plaatsen : foto's , video's, titels, namen, beschrijvingen ... datums
\r\nview : hoe je website de gegevens krijgt van onze modellen en voor de gebruikers verwerkt.
\r\ntemplate : de weergave van de gegevens op de website. Bestaande Tools HTML, CSS en Javascript
\r\n\r\n
standaard worden een aantal apps automatisch toegevoegd aan het Django Project
\r\n\r\nhet mooie is : een app is herbruikbaar , je kunt dezelfde app in meerdere projecten gebruiken
\r\niedere app : admin.py, models.py, views.py en urls.py (meestal)
object-relational mapper
\r\n\r\nDjango Model : beschrijft je tabel van je database records (in models.py)
\r\n\r\neenvoudige manipulatie van je gegevens zonder complexe SQL re moeten schrijven
\r\nIn de meeste gevallen worden er relaties gelegd tussen je gegevens
een op een (OnetoOne) ; één op veel relatie (OnetoMany) ; veel op veel relatie (ManyToMany)
\r\n\r\n\r\n\r\n
Django maakt automatisch je tabellen en indexen in je database
\r\n\r\nDjango biedt 4 basisdatabasefuncties : Creëren, lezen, bijwerken en verwijderen
\r\n\r\nCRUD : Create, Read, Update en Delete
\r\n\r\npython API .... application program interface : data in XML formaat of JSON (Java Script Object Notation) formaat
\r\n\r\npython manage.py shell
\r\n\r\nautomatisch gegenereerde admin functie
\r\n\r\neen eenvoudige database kan gebruikt worden : SQLITE3.
\r\n\r\nAlsook MySQL, MariaDB , PostgreSQL Oracle, ... kan gebruikt worden.
\r\n\r\nDjango ondersteuning internationalizering i18n en ondersteuning verschillende tijdzones
\r\n\r\nwebtoepassingen in andere talen : spellingscontrole in het Nederlands
\r\n\r\ntijdzones : nul meridiaan van Greenwich = UTC
\r\n\r\nwij : UTC + 1
\r\n\r\nzie 20 postcodes per pagina ipv 50
\r\n\r\nin pdf formaat : doc in pdf formaat
\r\n\r\npython beschikt over zeer uitgebreide pakketten , je moet hier het wiel niet terug uitvinden meestal zal je hier gebruik kunnen maken van reeds geschreven software
\r\n\r\nvoorbeeld : als de webcam van je laptop wilt gebruiken om qrcodes of streepjescode wilt scannen dan kun je bestaande speciale python pakketten hiervoor gebruiken !
\r\n\r\n\r\n\r\ndatabase
\r\n\r\nstandaard SQLITE3 documentatie : sqlite3 documentatie
\r\n\r\nandere database : MySQL, PostgreSQL, ORACLE, SAP, IBM_DB2, ODBC
\r\n\r\nmeest populaire django websites
\r\n\r\nallerlei formulier widgets zijn mogelijk : 'TextInput', 'NumberInput', 'EmailInput', 'URLInput', 'PasswordInput', 'HiddenInput', 'MultipleHiddenInput', 'FileInput', 'ClearableFileInput', 'Textarea', 'DateInput', 'DateTimeInput', 'TimeInput', 'CheckboxInput', ...
\r\n\r\nkalender
\r\n\r\nbij een datum veld , klik en er komt een maandkalender te voorschijn
\r\n\r\nscrolbaar per dag, maand en jaar
\r\n\r\nvoordeel : onafhankelijk van nieuwere software
\r\n\r\nverschillende tools voor een virtuele omgeving
\r\n\r\ndjango-admin startproject naamproject
\r\n\r\npython manage.py startapp naamapp
\r\n\r\npython manage.py createsuperuser
\r\n\r\n models.py
\r\n python manage.py makemigrations
\r\n python manage.py migrate
python manage.py runserver
\r\nhttp://127.0.0.1:8000 toont het django raamwerk
\r\nhttp://127.0.0.1:8000/admin toont het django raamwerk in admin mode
bootstrap 4.5.0 : zie bootstrap4 tutorial w3schools
\r\n\r\n Voordelen van Bootstrap:
\r\n Eenvoudig in gebruik: iedereen met alleen basiskennis van HTML en CSS kan Bootstrap gaan gebruiken
\r\n Responsieve functies: de CSS van Bootstrap past zich aan op smartphones, tablets en desktops
\r\n Mobile benadering: in Bootstrap : stijlen maken deel uit van het kernraamwerk
\r\n Browsercompatibiliteit: Bootstrap 4 is compatibel met alle moderne browsers (Chrome, Firefox, Internet Explorer 10+, Edge, Safari en Opera)
nieuw bootstrap 5.0
\r\n\r\n", "db_count": 278 }, { "taaknaam": "01. Django project adressenproject", "taaktext": "
\r\n\r\n
\r\n\r\n
postcode lijst : zie views.py class PostcodeListView : paginate_by = 50
\r\n\r\n57 paginas van telkens 50 postcodes : 56 * 50 + 25 = 2825 ; uitgenomen laatste pagina
\r\n\r\nindien paginering op 30 ipv 50 : 95 paginas van telkens 30 postcodes : 94 * 30 + 5 = 2825
\r\n\r\nListView's : simpel
\r\n\r\nPersoonListView, AdresListView, EmailListView, TelefoonListView, PostcodeListView
\r\n\r\nmodel= , template_name=, paginate_by=
\r\n\r\nDetailView's : simpel
\r\n\r\nPersoonDetailView, AdresDetailView, EmailDetailView, TelefoonDetailView, PostcodeDetailView
\r\n\r\ntemplate_name=
\r\n\r\ndef get_object(self): .....
\r\n\r\n(PersoonDetailView iets ingewikkelder daar naast Persoon ook zijn Adres, Email en Telefoon moet getoond worden
\r\n\r\nCreateView's : simpel
\r\n\r\nPersoonCreate, AdresCreate, EmailCreate, TelefoonCreate
\r\n\r\nUpdateView's : simpel
\r\n\r\nPersoonUpdate, AdresUpdate, EmailUpdate, TelefoonUpdate, PostcodeUpdate
\r\n\r\nDeleteView's : simpel
\r\n\r\nPersoonDelete, AdresDelete, EmailDelete, TelefoonDelete
\r\n\r\nZoek TemplateView's
\r\n\r\nCreate2
\r\n\r\n\r\n\r\n
Welkom op de Adressen administratie site, ontwikkelt met de modernste skeleton web framework = Django.
\r\n Met Django is het mogelijk om vlugger en met minder code Website applicaties te maken.
\r\n Het maakt gebruik van het MVC ontwerppatroon : complexe toepassingen worden ontworpen in drie eenheden = M(Model)-V(View)-C(Controller).
\r\n Het datamodel zit in het Model, de datapresentatie in het View en de applicatielogica in de Controller.
\r\n Het scheiden van deze verantwoordelijkheden bevordert de leesbaarheid en herbruikbaarheid van code.
Het maakt ook dat bijvoorbeeld veranderingen in de gebruikersinterface niet direct invloed hebben op het datamodel en vice versa.
\r\n Het maakt gebruik van de serverloze Sqlite database dmv. de Python programmeertaal.
De Django Documentatie kun je vinden op Django doc versie 3.0 .
\r\n\r\n\r\n\r\n
\r\n\r\n
\r\n\r\n
\r\n\r\n
\r\n\r\n\r\n\r\n
db_count is een intern tellertje dat bijhoudt hoeveel maal een welbepaalde taak bekeken is.
\r\n\r\n", "db_count": 174 }, { "taaknaam": "03. Django project cgcproject", "taaktext": "
\r\n\r\n
\r\n\r\n
wijzig een cgclid / creëer een nieuw cgclid vereist Log in
\r\n\r\nenkel de staff gebruiker kan alles en is zogenaamde administrator van dit cgcproject
\r\n\r\nSignup functie
\r\n\r\ntest_persoon1 J01Bizet_1
\r\ntest_persoon2 J01Bizet_2
\r\ntest_persoon3 J01Bizet_3
\r\ntweemaal signup met test_persoon1 gaat niet
test_persoon1, 2 en 3 geen toegang
\r\n\r\nenkel administrator ulefr01 (staff gebruiker) : staff status en superuser status
\r\n\r\nsoorten toegang : add(=toevoegen), change(=wijzigen), delete (=weggooien) en view (=bekijken)
\r\nNOOT = view laten we hier toe
test_persoon1 :
\r\n\r\nvoeg email adres toe
\r\n\r\nmet toegang add_cgclid, change_cgclid, delete_cgclid en view_cgclid
\r\n\r\ntest_persoon2 :
\r\n\r\nmet toegang change_cgclid en view_cgclid
\r\n\r\ntest_persoon3 :
\r\n\r\nmet toegang add_adres, change_adres, delete_adres en view_cgclid
\r\n(geen add_cgclid, change_cgclid, delete_cgclid !)
creëer nieuwe cgcleden, wijzig cgcleden, delete cgcleden, nieuw adres, nieuwe vergadering gebruik hiervoor de verschillende test_persoon1, 2 en 3 gebruikers
\r\n\r\nwijzig wachtwoord
\r\n\r\ndoe volgende tests
\r\n\r\ngebruik ulefr01, check registraties op 18 mei 2019
\r\nwijzig vergadering 18 mei 2019
wijzig datum naar 17 mei 2019
\r\nverzenden
bekijk nu registraties : registraties op 18 mei zijn gewijzigd naar 17 mei : sql werkt goed !
\r\nwijzig datum terug naar 18-05-2019
bekijk vergadering van 11 januari 2020
\r\nbekijk vergadering van 14 december 2019
scannen streepjescodes/qrcodes met webcam van laptop : ./scanner.py
\r\n\r\nDe reguliere regressie van de CGC lidcodes moet voldoen aan re.match("^[A-Z]{2}/[0-9]{2}/[0-9]{2}")
\r\n\r\ncat registraties_2019-09-10.txt | sort -u >registraties_2019-09-10.csv
\r\n\r\nvereist : vergadering met registratie datum moet gecreerd zijn in de sql database
\r\npython opladen_aanwezigen.py -h
\r\n * opladen_aanwezigen.py -b <database> -d <datum> in formaat=yyyy-mm-dd
\r\npython opladen_aanwezigen.py -b db.sqlite3 -d 2019-10-12
\r\n * datum is = 2019-10-12
\r\n * database is = db.sqlite3
\r\n * vergadid = 11
\r\n * filenaam = registraties_2019-10-12.csv
grafische presentatie van aanwezigen met de python matplotlib tool
\r\n\r\nhet plotten gebeurt met de "fivethirtyeight" stijl , het totaal aantal CGCleden worden getoond per per datum van de CGC vergadering
\r\n\r\npython qrcode.py "TE/01/01" test.qrcode.png
\r\n\r\nzbarimg stevens.qrcode.png
\r\n\r\n./backup_registraties
\r\n\r\n./backup_database
\r\n output is sqlite3_20191013.db
", "db_count": 168 }, { "taaknaam": "04. Django project weerproject", "taaktext": "
\r\n\r\n
op het internet wordt data uitgewisselt over het web, meestal wordt het JSON formaat (Java Script Object Notering) gebruikt om gegevens door te spelen
\r\n\r\nweer API met parameters q = stad, units = metric en lang = nl voor nederlands met API key
\r\n\r\ncurl -s 'http://api.openweathermap.org/data/2.5/weather?q=Deerlijk&units=metric&lang=nl&appid=5cf01f009b7d0178a211d460f3ac67d7' | jq
\r\n\r\nIndien Http-response = 200 dan is de stad gevonden met de accuweather API
\r\n\r\nIndien Http-response <> 200 dan is de stad niet gevonden en wordt de foutboodschap : "Stad bestaat niet in deze wereld !" getoond en wordt er geen nieuwe stad ind dedatabase gecreeerd.
\r\n\r\nIndien Stad al in de database zit dan wordt de boodschap : "Stad bestaat reeds in de database !" getoond en wordt er geen nieuwe stad ind dedatabase gecreeerd.
\r\n\r\nPer stad worden de temperatuur, beschrijving, een icoon, de tijdzone en het land getoond.
\r\n\r\nHet json formaat van de gevonden API wordt getoond bij het opstarten van de website.
\r\n\r\nStad Sydney
\r\n\r\n{'coord': {'lon': 151.21, 'lat': -33.87}, 'weather': [{'id': 500, 'main': 'Rain', 'description': 'lichte regen', 'icon': '10d'}], 'base': 'stations', 'main': {'temp': 15.18, 'feels_like': 13.66, 'temp_min': 12.78, 'temp_max': 17, 'pressure': 1022, 'humidity': 88}, 'visibility': 10000, 'wind': {'speed': 3.6, 'deg': 230}, 'rain': {'1h': 0.25}, 'clouds': {'all': 40}, 'dt': 1587934106, 'sys': {'type': 1, 'id': 9600, 'country': 'AU', 'sunrise': 1587932796, 'sunset': 1587971924}, 'timezone': 36000, 'id': 2147714, 'name': 'Sydney', 'cod': 200}
\r\n{'stad': <Stad: Sydney>, 'temperatuur': 15.18, 'beschrijving': 'lichte regen', 'icoon': '10d', 'tijdzone': 'UTC+10u', 'land': 'AU'}
Stad Tokyo
\r\n\r\n{'coord': {'lon': 139.69, 'lat': 35.69}, 'weather': [{'id': 803, 'main': 'Clouds', 'description': 'zwaar bewolkt', 'icon': '04d'}], 'base': 'stations', 'main': {'temp': 13, 'feels_like': 10.58, 'temp_min': 12.22, 'temp_max': 13.33, 'pressure': 1015, 'humidity': 76}, 'visibility': 10000, 'wind': {'speed': 3.1, 'deg': 30}, 'clouds': {'all': 75}, 'dt': 1587934150, 'sys': {'type': 1, 'id': 8074, 'country': 'JP', 'sunrise': 1587930817, 'sunset': 1587979431}, 'timezone': 32400, 'id': 1850144, 'name': 'Tokyo', 'cod': 200}
\r\n{'stad': <Stad: Tokyo>, 'temperatuur': 13, 'beschrijving': 'zwaar bewolkt', 'icoon': '04d', 'tijdzone': 'UTC+9u', 'land': 'JP'}
\r\n
Stad Wellington
\r\n\r\n{'coord': {'lon': 174.78, 'lat': -41.29}, 'weather': [{'id': 804, 'main': 'Clouds', 'description': 'geheel bewolkt', 'icon': '04d'}], 'base': 'stations', 'main': {'temp': 15.2, 'feels_like': 8.72, 'temp_min': 14.44, 'temp_max': 16, 'pressure': 1016, 'humidity': 77}, 'visibility': 10000, 'wind': {'speed': 9.8, 'deg': 360, 'gust': 15.4}, 'clouds': {'all': 97}, 'dt': 1587934258, 'sys': {'type': 1, 'id': 7358, 'country': 'NZ', 'sunrise': 1587927821, 'sunset': 1587965587}, 'timezone': 43200, 'id': 2179537, 'name': 'Wellington', 'cod': 200}
\r\n{'stad': <Stad: Wellington>, 'temperatuur': 15.2, 'beschrijving': 'geheel bewolkt', 'icoon': '04d', 'tijdzone': 'UTC+12u', 'land': 'NZ'}
\r\n
Stad Zulte
\r\n\r\n{'coord': {'lon': 3.45, 'lat': 50.92}, 'weather': [{'id': 800, 'main': 'Clear', 'description': 'onbewolkt', 'icon': '01n'}], 'base': 'stations', 'main': {'temp': 9.73, 'feels_like': 7.37, 'temp_min': 8.89, 'temp_max': 10.56, 'pressure': 1010, 'humidity': 69}, 'wind': {'speed': 1.57, 'deg': 45}, 'clouds': {'all': 0}, 'dt': 1587934311, 'sys': {'type': 3, 'id': 19993, 'country': 'BE', 'sunrise': 1587875306, 'sunset': 1587927549}, 'timezone': 7200, 'id': 2783151, 'name': 'Zulte', 'cod': 200}
\r\n{'stad': <Stad: Zulte>, 'temperatuur': 9.73, 'beschrijving': 'onbewolkt', 'icoon': '01n', 'tijdzone': 'UTC+2u', 'land': 'BE'}
\r\n
wat doorgegeven wordt naar template in json formaat wordt :
\r\n\r\n{
\r\n "stad": "Sydney",
\r\n "temperatuur": 15.16,
\r\n "beschrijving": "half bewolkt",
\r\n "icoon": "03d",
\r\n "tijdzone": "UTC+10u",
\r\n "land": "AU"
\r\n}
\r\n{
\r\n "stad": "Tokyo",
\r\n "temperatuur": 13.66,
\r\n "beschrijving": "zwaar bewolkt",
\r\n "icoon": "04d",
\r\n "tijdzone": "UTC+9u",
\r\n "land": "JP"
\r\n}
\r\n{
\r\n "stad": "Wellington",
\r\n "temperatuur": 15.2,
\r\n "beschrijving": "geheel bewolkt",
\r\n "icoon": "04d",
\r\n "tijdzone": "UTC+12u",
\r\n "land": "NZ"
\r\n}
\r\n{
\r\n "stad": "Zulte",
\r\n "temperatuur": 8.17,
\r\n "beschrijving": "onbewolkt",
\r\n "icoon": "01n",
\r\n "tijdzone": "UTC+2u",
\r\n "land": "BE"
\r\n}
Een nieuwe stad kan toegevoegd worden in de database en een willekeurige stad in de database kan weggedaan worden.
", "db_count": 172 }, { "taaknaam": "05. Django project enqueteproject", "taaktext": "\r\n\r\n
\r\n\r\n
Volgende vragen worden in de database gestopt :
\r\n\r\n1) Wat is je favoriete programmeerttaal ?
\r\n\r\n6 keuzes :
\r\n\r\n2) Wat is je favoriete Ioerating Systeem ?
\r\n\r\n5 keuzes :
\r\n\r\n3) Wat is je favoriete Python Framework ?
\r\n\r\n3 keuzes :
\r\n\r\n\r\n\r\n
\r\n\r\n
", "db_count": 158 }, { "taaknaam": "06. Django template language DTL", "taaktext": "
{% %}
\r\n\r\nextends "base.html
\r\n\r\ncsrf_token
\r\n\r\nload static
\r\nload tz indien USE_TZ = TRUE
\r\nload l10n indien USE_L10N = TRUE
\r\nload i18n
\r\n\r\n
block content
\r\nendblock | endblock content
\r\n\r\n
block title
\r\nendblock title
\r\n\r\n
block body
\r\nendblock body
\r\n\r\n
for .... in .....
\r\n\r\nempty
\r\n\r\n<li> set is empty </li>
\r\n\r\nendfor
\r\n\r\nfor member in owner.member_set.all
\r\n\r\nvalue|default: "....."
\r\n\r\nvalue|length
\r\nvalue|filesizeformat
if var1
\r\n\r\n{ { var1 } }
\r\n\r\nelif var2
\r\n\r\n{ { var2 } }
\r\n\r\nelse
\r\nendif
firstof var1 var2 var3
\r\nforloop.counter
\r\nforloop.first
\r\nforloop.last
if var == '....'
\r\nif var != '....'
\r\nif var < ...
>
\r\n<=
\r\n>=
if var is True
\r\nif var is None
\r\nif var is not True
\r\nif var is not None
\r\nif a<b and c<d
\r\nif a>b or c<d
\r\nif messages|length >= 100
ifequal a b
\r\nendifequal
ifnotequal a b
\r\nendifnotequal
ifchanged
\r\nendifchanged
comment
\r\nendcomment
include ".....html'
\r\n\r\nnow "d-m-Y"
\r\n\r\nurl ' '
\r\n\r\n\r\n\r\n
{ { } }
\r\n\r\nobject
\r\nobject.veld
value | capfirst
\r\nvalue | center: "15"
\r\nvalue | cut: "b"
\r\nvalue | date: "d/m/Y/H"
\r\nvalue | date: "SHORT_DATE_FORMAT"
\r\nvalue | default: " "
\r\nvalue | dictsort: " "
\r\nvalue | divisibleby: " "
\r\nvalue | first
\r\nvalue | floatformat: "-3"
\r\nvalue | git_digit: "2"
value | join: "// "
\r\n\r\nvalue | last
\r\nvalue | length
\r\nvalue | lower
\r\nvalue | ....
{# dit is commentaar #}
\r\n\r\n\r\n\r\n
\r\n
Do
\r\n\r\n\r\npost.author_id
\r\n\r\nDon't
\r\n\r\n\r\npost.author.id
\r\n\r\nIf you have a foreign key named author, Django will automatically store the primary key in the property author_id, while in the author property will be stored a lazy database reference. So if you access the id via the author instance, like this post.author.id
, it will cause an additional query.
Do
\r\n\r\n\r\nuser.groups.add(administrators, managers)
\r\n\r\nDon't
\r\n\r\n\r\nuser.groups.add(administrators)\r\nuser.groups.add(managers)
\r\n\r\nIf you only need the count:
\r\n\r\nDo
\r\n\r\n\r\nusers = User.objects.all()\r\nusers.count()\r\n\r\n# Or in template...\r\n{{ users.count }}
\r\n\r\nDon't
\r\n\r\n\r\nusers = User.objects.all()\r\nlen(users)\r\n\r\n# Or in template...\r\n{{ users|length }}
\r\n\r\nIf you only need to know if the queryset is empty:
\r\n\r\nDo
\r\n\r\n\r\ngroups = Group.objects.all()\r\nif groups.exists():\r\n # Do something...
\r\n\r\nDon't
\r\n\r\n\r\ngroups = Group.objects.all()\r\nif groups:\r\n # Do something...
\r\n\r\nDo
\r\n\r\n\r\nreview = Review.objects.select_related('author').first() # Select the Review and the Author in a single query\r\nname = review.author.first_name
\r\n\r\nDon't
\r\n\r\n\r\nreview = Review.objects.first() # Select the Review\r\nname = review.author.first_name # Additional query to select the Author
\r\n\r\nLet’s say the Invoice model has 50 fields and you want to create a view to display just a summary, with the number, date and value:
\r\n\r\nDo
\r\n\r\n\r\n# views.py\r\n# If you don't need the model instance, go for:\r\ninvoices = Invoice.objects.values('number', 'date', 'value') # Returns a dict\r\n\r\n# If you still need to access some instance methods, go for:\r\ninvoices = Invoice.objects.only('number', 'date', 'value') # Returns a queryset\r\n\r\n# invoices.html\r\n<table>\r\n {% for invoice in invoices %}\r\n <tr>\r\n <td>{{ invoice.number }}</td>\r\n <td>{{ invoice.date }}</td>\r\n <td>{{ invoice.value }}</td>\r\n </tr>\r\n {% endfor %}\r\n</table>
\r\n\r\nDon't
\r\n\r\n\r\n# views.py\r\ninvoices = Invoice.objects.all()\r\n\r\n# invoices.html\r\n<table>\r\n {% for invoice in invoices %}\r\n <tr>\r\n <td>{{ invoice.number }}</td>\r\n <td>{{ invoice.date }}</td>\r\n <td>{{ invoice.value }}</td>\r\n </tr>\r\n {% endfor %}\r\n</table>
\r\n\r\nDo
\r\n\r\n\r\nfrom django.db.models import F\r\n\r\nProduct.objects.update(price=F('price') * 1.2)
\r\n\r\nDon't
\r\n\r\n\r\nproducts = Product.objects.all()\r\nfor product in products:\r\n product.price *= 1.2\r\n product.save()
",
"db_count": 158
},
{
"taaknaam": "08. Django Sitemap",
"taaktext": "Binnen django is er een ingebouwde sitemap framework :
\r\n\r\nEen XML bestand : sitemap.xml is ter beschikking dat de zoekmachine bepaalt hoe dikwijls een website pagina is aangepast of gecreeerd ....
\r\n\r\n\r\n\r\n
De sitemap framework vereist een update van onze database :
\r\n\r\nXML bestand
\r\n\r\nHet XML bestand maak gebruik van ' example.com
' voor de naam van onze website. Diit komt van de 'sites
framework'.
Dit kan aangepast worden als je in Django admin mode gaat dan kun je Sites
aanpassen in de sectie WebSites . .
Dotenv is een manier om geheime sleutels (publieke als secret) en wachtwoorden op te slaan in environment variabelen.
\r\n\r\nDeze worden opgeslagen in een .env bestand. het bestand .gitignore moet het bestand .env bevatten zodat dit bestand niet opgeladen wordt in github dit om te voorkomen dat deze sleutels openbaar worden !
\r\n\r\nOm gebruik te kunnen maken van dotenv moet het python pakket python-dotenv geinstalleerd worden.
\r\n\r\n\r\n\r\n\r\npip install python-dotenv
\r\n
\r\n\r\n\r\nexport DJANGO_SETTINGS_MODULE=django_project_naam.settings.prod
\r\n\r\n
\r\nexport SECRET_KEY='mijn_secret_key'
\r\nexport EMAIL_HOST_PASSWORD='geheim_wachtwoord '
\r\nexport STRIPE_LIVE_PUBLIC_KEY='live_publieke_sleutel'
\r\nexport STRIPE_LIVE_SECRET_KEY='live_geheime_sleutel '
\r\nexport STRIPE_PUBLIC_KEY='test_publieke_sleutel ''
\r\n
\r\nexport STRIPE_SECRET_KEY='test_geheime_sleutel '
django_project_naam = naam van je django project gemaakt met de django-admin tool
\r\n\r\nsettings.prod ofwel settings
\r\n\r\nmijn_secret_key = kan opnieuw gegenereerd worden op website : https://miniwebtool.com/django-secret-key-generator/
\r\n\r\n\r\n\r\n\r\nimport os
\r\n\r\n
\r\nfrom dotenv import load_dotenvproject_folder = os.path.expanduser('~/mijn_project_naam')
\r\n\r\nload_dotenv(os.path.join(project_folder, '.env'))
\r\n
\r\nfrom django.core.wsgi import get_wsgi_application
\r\napplication = get_wsgi_application()
mijn_project_naam = naam van je django naam folder-map
\r\n\r\n\r\n\r\n\r\n#!/bin/bash
\r\n\r\n
\r\n# This hook is sourced after this virtualenv is activated.set -a; source ~/mijn_project_naam/.env;
\r\n
\r\n
\r\n\r\n\r\nSECRET_KEY = os.environ['SECRET_KEY']
\r\n\r\n...
\r\n\r\nINSTALLED_APPS = [
\r\n\r\n'accounts.apps.AccountsConfig',
\r\n\r\n
\r\n 'django.contrib.admin',
\r\n 'django.contrib.auth',
\r\n 'django.contrib.contenttypes',
\r\n 'django.contrib.sessions',
\r\n 'django.contrib.messages',
\r\n 'django.contrib.staticfiles',
\r\n 'django.contrib.sites',
\r\n 'django.contrib.sitemaps',
\r\n 'django.contrib.humanize',
\r\n 'django_extensions',
\r\n 'land',
\r\n 'ckeditor',
\r\n 'ckeditor_uploader',
\r\n 'robots'
\r\n 'base',]
\r\n\r\n...
\r\n\r\nLANGUAGE_CODE = 'nl'
\r\n\r\nTIME_ZONE = 'Europe/Brussels'
\r\n\r\n...
\r\n\r\nSTATIC_URL = '/static/'
\r\n\r\nMEDIA_URL = '/media/'
\r\n\r\n
\r\nMEDIA_ROOT = os.path.join(BASE_DIR, 'media/')CKEDITOR_CONFIGS = {
\r\n\r\n
\r\n 'default': {
\r\n # Editor Width Adaptation
\r\n 'width':'auto',
\r\n 'height':'250px',
\r\n # tab key conversion space number
\r\n 'tabSpaces': 4,
\r\n # Toolbar Style
\r\n 'toolbar': 'full',
\r\n # 'Custom',
\r\n # Toolbar buttons
\r\n # 'toolbar_Custom': [
\r\n # # Emotional Code Block
\r\n # ['Smiley', 'CodeSnippet'],
\r\n # # Font Style
\r\n # ['Bold', 'Italic', 'Underline', 'RemoveFormat', 'Blockquote'],
\r\n # # Font color
\r\n # ['TextColor', 'BGColor'],
\r\n # # Link link
\r\n # ['Link', 'Unlink'],
\r\n # # List of items
\r\n # ['NumberedList', 'BulletedList'],
\r\n # # Maximization
\r\n # ['Maximize']
\r\n # ],
\r\n # Add Prism related plug-ins
\r\n 'extraPlugins': ','.join(['codesnippet', 'widget', 'lineutils']),
\r\n }
\r\n}CKEDITOR_UPLOAD_PATH = 'upload/'
\r\n\r\n
\r\nCKEDITOR_IMAGE_BACKEND = 'pillow'LOGIN_URL = '/accounts/login/'
\r\n\r\n
\r\nLOGIN_REDIRECT_URL = "/"
\r\nLOGOUT_REDIRECT_URL = "/"\r\n\r\n
\r\nEMAIL_USE_TLS= True
\r\nEMAIL_HOST= 'smtp.gmail.com'
\r\nEMAIL_PORT= 587
\r\nDEFAULT_FROM_EMAIL = 'ulefr01.pythonanywhere.com'
\r\nEMAIL_HOST_USER= 'ulefr01@gmail.com'
\r\nEMAIL_HOST_PASSWORD= os.environ['EMAIL_HOST_PASSWORD']
\r\nEMAIL_BACKEND='django.core.mail.backends.smtp.EmailBackend'LOG_DIR = os.path.join(BASE_DIR, 'log')
\r\n\r\nLOGGING = {
\r\n
\r\n 'version': 1,
\r\n 'disable_existing_loggers': False,
\r\n # Debugger is active
\r\n 'handlers': {
\r\n 'django_all': {
\r\n 'class': 'logging.FileHandler',
\r\n 'filename': os.path.join(LOG_DIR, 'django.log'),
\r\n },
\r\n 'land_all': {
\r\n 'class': 'logging.FileHandler',
\r\n 'filename': os.path.join(LOG_DIR, 'land.log'),
\r\n },
\r\n },
\r\n 'loggers': {
\r\n 'django.server': {
\r\n 'handlers': ['django_all'],
\r\n 'level': 'DEBUG',
\r\n },
\r\n 'django.request': {
\r\n 'handlers': ['django_all'],
\r\n 'level': 'INFO',
\r\n },
\r\n # 'django.db.backends': {
\r\n # 'handlers': ['django_all'],
\r\n # 'level': 'DEBUG',
\r\n # },
\r\n 'adres': {
\r\n 'handlers': ['land_all'],
\r\n 'level': 'INFO',
\r\n },
\r\n },
\r\n}
\r\n\r\n\r\nfrom .base import *
\r\n\r\nDEBUG = True
\r\n\r\nALLOWED_HOSTS = [
\r\n\r\n
\r\n '127.0.0.2',
\r\n
\r\n]# met gunicorn en gebruik van .env
\r\n\r\n
\r\nSTATIC_ROOT = 'django_project_naam /static'STATICFILES_DIRS = [
\r\n\r\n
\r\n os.path.join(BASE_DIR, 'static/'),]
\r\n\r\n# met gunicorn volgende twee lijnen niet commentareren
\r\n\r\nSTRIPE_PUBLIC_KEY = os.environ['STRIPE_PUBLIC_KEY]'
\r\n\r\n
\r\nSTRIPE_SECRET_KEY = os.environ['STRIPE_SECRET_KEY]'# ofwel met ./manage-py runserver_plus zonder .env volgende twee lijnen
\r\n\r\n# STRIPE_PUBLIC_KEY = 'pk_test_....'
\r\n
\r\n# STRIPE_SECRET_KEY = 'sk_test_....'
\r\n
\r\n\r\n\r\nfrom .base import *
\r\n\r\nDEBUG = False
\r\n\r\nALLOWED_HOSTS = [
\r\n\r\n
\r\n 'ulefr03.eu.pythonanywhere.com'
\r\n ]# ./manage.py collectstatic (production only)
\r\n\r\n
\r\nSTATIC_ROOT = 'django_project_naam/static'STRIPE_LIVE_PUBLIC_KEY = os.environ['STRIPE_LIVE_PUBLIC_KEY]'
\r\n\r\n
\r\nSTRIPE_LIVE_SECRET_KEY = os.environ['STRIPE_LIVE_SECRET_KEY]'# secure in production
\r\n
\r\nSESSION_COOKIE_SECURE = True
\r\nCSRF_COOKIE_SECURE = True
\r\nSECURE_HSTS_SECONDS = 31536000
\r\nSECURE_HSTS_INCLUDE_SUBDOMAINS = True
\r\nSECURE_HSTS_PRELOAD = True
\r\nSECURE_SSL_REDIRECT = True
\r\nSECURE_REFERRER_POLICY = 'strict-origin'
\r\nSECURE_BROWSER_XSS_FILTER = True
\r\n\r\n\r\ndev.py aanpassen
\r\n\r\nstart een virtuele omgeving
\r\n\r\nvf activate env_django_project_naam
\r\n\r\nenkel in test (fish) : source .env
\r\n\r\ngunicorn -b 127.0.0.2:8000 -w 5 django_project_naam .wsgi
\r\n of\r\n\r\ngunicorn --bind = 127.0.0.2:8000 --workers = 5 django_project_naam .wsgi
\r\n
\r\n\r\n\r\nchrome probleem : Fix for Google Chrome favicon loading in Django. You may have noticed that Chrome has issues loading the appropriate favicon on Django if you have it in a different path other than just '/favicon.ico'.
\r\n\r\ntoevoegen in urls.py :
\r\n\r\nfrom django.views.generic.base import RedirectView
\r\n\r\npath('favicon.ico/', RedirectView.as_view(url='/static/css/favicon.ico')),
\r\n
zie : https://nl.wikipedia.org/wiki/Lijst_van_HTTP-statuscodes
\r\n\r\nbelangrijkste codes
\r\n\r\npython heeft een eigen pakketbeheerder = PIP
\r\nPIP is een Python-pakketbeheerder die wordt gebruikt om Python-pakketten van Python-pakketindex te installeren
https://www.python.org/
\r\nwat betreft : python about
\r\ndoc : python doc
\r\nleren : python leren
\r\nverschil met andere programeertalen :
\r\n inspringen (indentation)
\r\n geen begin/end
\r\n geen {/}
\r\n geen then/endif
\r\n python interpreter
\r\n niet voldaan dan krijg je een IndentationError : unexpected indent
verzamelingen
\r\n\r\n[ ..., ..., ... ] : list
\r\n\r\n{ ..., ..., ... } : dictionary
\r\n\r\n( ..., ..., ... ) : tuple
\r\n\r\nif/else
\r\n\r\nif [ .... <= .... ] :
\r\n\r\n.....
\r\n\r\n.....
\r\n\r\nelse:
\r\n\r\n....
\r\n\r\n....
\r\n\r\nformateren
\r\n\r\nformat % values
\r\n\r\n%s voor strings, %i integer, %f floating point, %X hexadecimaal, %c character,
\r\n\r\n" mijn naam is = (voornaam.= %s , familienaam = %s" % ("franz", "ulenaers")
\r\n\r\n", "db_count": 190 }, { "taaknaam": "12. CKEDITOR in Django", "taaktext": "
CKEditor is een online WYSIWYG (what you see is what you get) editor dat je kunt gebruiken in een webbrowser (Chrome, Firefox, Safari, Internet Explorer, ...)
\r\n\r\nHier de menu :
\r\n\r\n\r\n\r\nvoor meer zie : https://www.quackit.com/html/html_editors/
\r\n\r\nen https://www.quackit.com/html/online-html-editor/full/
", "db_count": 191 }, { "taaknaam": "Apt package tool", "taaktext": "titel: "apt"
\r\n\r\nbeschrijving: "Advanced Package Tool." "Het installeren van deb-pakketten op een Debian, Ubuntu .... Linux systeem"
\r\n\r\ncategoriën:
\r\n\r\n\r\n sudo apt update
\r\n\r\n sudo apt upgrade
\r\ninstalleer een pakket je-pakket-naam
\r\n\r\n\r\n sudo apt install <je-pakket-naam>
\r\ndoe een pakket je-pakket-naam weg
\r\n\r\n\r\n sudo apt remove <je-pakket-naam>
\r\ndoe een pakket je-pakket-naam volledig weg (alsook configuratie bestanden)
\r\n\r\n\r\n sudo apt purge <je-pakket-naam>
\r\n\r\n # aptitude search <je-pakket-naam> \r\n apt search <je-pakket-naam>
\r\n\r\n apt show <je-pakket-naam>\r\n # meer info met `apt-cache show`\r\n # apt-cache show <je-pakket-naam>
\r\napt-get clean
doet al de deb bestanden weg uit de map /var/cache/apt/archives/
\r\n sudo apt-get clean\r\n # of\r\n sudo apt clean
\r\napt autoclean
/ apt autoremove
kuist niet al de bestanden op uit je /var/cache/apt/archives !
\r\n # uitvoeren \r\n dpkg -l | grep '^rc'\r\n # enkel de naam van de pakketten\r\n # dpkg -l | grep "^rc" | awk '{print $2}'
\r\n\r\n sudo apt purge $(dpkg -l | grep \"^rc\" | awk '{print $2}')\r\n
\r\n\r\n\r\n # \r\n dpkg -l | grep '^hi\\|^ii\\|^i'\r\n # enkel de naam van de pakketten\r\n # dpkg -l | grep '^hi\\|^ii\\|^i' | awk '{print $2}'
\r\napt-cache policy $(dpkg -l | grep "^hi|^ii|^i" | awk '{print $2}')
\r\n\r\napt-cache policy $(dpkg -l | grep "^hi|^ii|^i" | awk '{print $2}') >~/outputs/aptlog_pakketten_20220721.out
\r\n\r\n\r\n # sid = unstable is testing debian 12 goto https://packages.debian.org/sid/amd64\r\n # trixie = debian 13 in 2025\r\n # bookworm = testing debian 12 16/08/2021\r\n # bullseye = stable debian 11 03/2021\r\n # buster = oldstable debian 10\r\n # stretch = oldstable debian 9\r\n # jessie = oldstable debian 8\r\n # deb cdrom:[Official Debian GNU/Linux Live 11.0.0 gnome 2021-08-14T11:22]/ bullseye main\r\n # deb cdrom:[Official Debian GNU/Linux Live 11.0.0 gnome 2021-08-14T11:22]/ bullseye main\r\n deb http://ftp.be.debian.org/debian/ experimental main contrib non-free\r\n deb http://ftp.be.debian.org/debian/ testing main contrib non-free\r\n deb http://ftp.be.debian.org/debian/ bullseye main contrib non-free\r\n deb http://ftp.be.debian.org/debian/ buster main contrib non-free\r\n # deb-src http://ftp.be.debian.org/debian/ bullseye main\r\n deb http://security.debian.org/debian-security testing-security main contrib non-free\r\n deb http://security.debian.org/debian-security bullseye-security main contrib non-free\r\n # deb-src http://security.debian.org/debian-security bullseye-security main\r\n # bullseye-updates, to get updates before a point release is made;\r\n # see https://www.debian.org/doc/manuals/debian-reference/ch02.en.html#_updates_and_backports\r\n deb http://ftp.be.debian.org/debian/ testing-updates main contrib non-free\r\n deb http://ftp.be.debian.org/debian/ bullseye-updates main contrib non-free\r\n # deb-src http://ftp.be.debian.org/debian/ bullseye-updates main\r\n deb http://ftp.be.debian.org/debian testing-backports main contrib non-free\r\n deb http://ftp.be.debian.org/debian bullseye-backports main contrib non-free
\r\n\r\n # \r\n Package: *\r\n Pin: release a=bullseye-backports\r\n Pin-Priority: 100\r\n Package: *\r\n Pin: release a=bullseye\r\n Pin-Priority: 500\r\n Package: *\r\n Pin: release a=testing\r\n Pin-Priority: -1
\r\n\r\n\r\n\r\nnoot: je kunt wel nog pakketten type testing installeren met
\r\napt install -t testing je_pakket
!
\r\n sudo apt -t bullseye-backports upgrade
\r\n\r\n aptitude search '?obsolete'
\r\noutput is
\r\n\r\n\r\n i boostnote.next - . \r\n i element-desktop - A feature-rich client for Matrix.org \r\n i gir1.2-appindicator3-0.1 - Typelib files for libappindicator3-1 \r\n i hibernate - smartly puts your computer to sleep (suspend to RAM o\r\n i A libappindicator3-1 - allow applications to export a menu into the panel --\r\n i A libffi6 - Foreign Function Interface library runtime \r\n i A libindicator3-7 - panel indicator applet - shared library \r\n i A libvala-0.52-0 - C# like language for the GObject system - library \r\n i A libvala-0.52-dev - C# like language for the GObject system - development\r\n i A python-cairo - Python bindings for the Cairo vector graphics library\r\n i A python-feedparser - Universal Feed Parser for Python \r\n i A python-gobject-2 - deprecated static Python bindings for the GObject lib\r\n i python-gtk2 - Python bindings for the GTK+ widget set \r\n i A python-libxml2 - Python bindings for the GNOME XML library \r\n i A python-numpy - Numerical Python adds a fast array facility to the Py\r\n i A python-tidylib - Python 2 wrapper for HTML Tidy (tidylib) \r\n i A python-utidylib - Python wrapper for TidyLib \r\n i rawdog - RSS Aggregator Without Delusions Of Grandeur \r\n i A uswsusp - tools to use userspace software suspend provided by L
\r\n\r\n apt-cache policy 'gnome*'
\r\ncheck for gnome test versions
\r\n\r\n\r\n apt-cache policy $(dpkg -l | grep '^ii\\^hi\\^i' | awk '{print $2}'| grep 'gnome')
\r\ndit al je geen buster hebt in je sources.list maar toch buster pakketten geinstalleerd zijn !!!
\r\n\r\n\r\n apt list | grep lokaal
\r\n\r\n\r\n\r\noutput
\r\n
\r\n gir1.2-appindicator3-0.1/now 0.4.92-7 amd64 [geïnstalleerd,lokaal]\r\n hibernate/now 2.0+15+g88d54a8-1 all [geïnstalleerd,lokaal]\r\n libappindicator3-1/now 0.4.92-7 amd64 [geïnstalleerd,lokaal]\r\n libffi6/now 3.2.1-9 amd64 [geïnstalleerd,lokaal]\r\n libindicator3-7/now 0.5.0-4 amd64 [geïnstalleerd,lokaal]\r\n libvala-0.52-0/now 0.52.5-1 amd64 [geïnstalleerd,lokaal]\r\n libvala-0.52-dev/now 0.52.5-1 amd64 [geïnstalleerd,lokaal]\r\n python-cairo/now 1.16.2-1+b1 amd64 [geïnstalleerd,lokaal]\r\n python-feedparser/now 5.2.1-1 all [geïnstalleerd,lokaal]\r\n python-gobject-2/now 2.28.6-13+b1 amd64 [geïnstalleerd,lokaal]\r\n python-gtk2/now 2.24.0-5.1+b1 amd64 [geïnstalleerd,lokaal]\r\n python-libxml2/now 2.9.4+dfsg1-7+deb10u2 amd64 [geïnstalleerd,lokaal]\r\n python-numpy/now 1:1.16.2-1 amd64 [geïnstalleerd,lokaal]\r\n python-tidylib/now 0.3.2~dfsg-4 all [geïnstalleerd,lokaal]\r\n python-utidylib/now 0.5-2 all [geïnstalleerd,lokaal]\r\n rawdog/now 2.23-2 all [geïnstalleerd,lokaal]\r\n uswsusp/now 1.0+20120915-6.2 amd64 [geïnstalleerd,lokaal]\r\n
\r\n\r\n sudo apt install unattended-upgrades apt-listchanges\r\n sudo apt install apt-config-auto-update\r\n sudo apt install powermgmt-base
\r\n\r\n sudo nano /etc/apt/apt.conf.d/50unattended-upgrades
\r\n\r\n zet in het bestand 50unattended-upgrades :\r\n
\r\n\r\n\r\n "origin=Debian,codename=${distro_codename}-updates";\r\n// "origin=Debian,codename=${distro_codename}-proposed-updates";\r\n "origin=Debian,codename=${distro_codename},label=Debian";\r\n "origin=Debian,codename=${distro_codename},label=Debian-Security";\r\n "origin=Debian,codename=${distro_codename}-security,label=Debian-Security";\r\n\r\n Unattended-Upgrade::Mail "root";\r\n\r\n Unattended-Upgrade::Automatic-Reboot "true";\r\n\r\n Unattended-Upgrade::Automatic-Reboot-WithUsers "true";\r\n
\r\n\r\n sudo nano /etc/apt/apt.conf.d/51unattended-upgrades-local
\r\n\r\n zet in het bestand 51unattended-upgrades-local :\r\n
\r\n\r\n\r\n Unattended-Upgrade::Origins-Pattern {\r\n\t"origin=*";\t\r\n };
\r\n\r\n # steek stekker in stopcontact zodat je niet op batterij werkt\r\n sudo unattended-upgrades
\r\n\r\n sudo -i\r\n cd /var/log/unattended-upgrades/\r\n ls
\r\ncronjob maken met crontab
\r\n\r\n\t\r\n bijvoorbeeld elke dag om 22:00\r\n
\r\n\t\r\n nano /etc/crontab
\r\n\r\n voeg volgende lijn toe in bestand /etc/contab\r\n
\r\n\r\n\r\n 00 22 * * * /usr/bin/unattended-upgrade -v
\r\n\r\n nano /etc/rsyslog.d/50-default.conf
\r\n\r\n voeg volgende lijn toe\r\n
\r\n\r\n\r\n #\r\n cron.* /var/log/cron.log\r\n #
\r\n\r\n check cronjob log in /var/log/cron.log\r\n
\r\n\r\n\r\n apt list --upgradable\r\n systemctl status cron\r\n cat /etc/crontab\r\n systemctl status rsyslog\r\n systemctl status unattended-upgrade\r\n cat /var/log/cron.log
\r\n\r\n#!/bin/bash\r\n# backup op backup2\r\nLD=\"/backup2/\"\r\nDATUM=\"$(date +%Y%m%d)\"\r\nLF=backupdisk_$(date +%Y%m%d).out\r\nRES=1\r\n# only run as root\r\nif [ \"$(id -u)\" != '0' ]\r\nthen\r\n echo \"Deze bash script moet opgestart worden met root rechten\"\r\n exit $RES\r\nfi\r\necho \"====== start backupdisk_sets ======\"\r\necho \"====== start backupdisk_sets ======\" >>$LD$LF\r\necho \"-----------------------------------\" >>$LD$LF\r\necho \" inxi \"\r\necho \" inxi \" >>$LD$LF\r\necho \"------\" >>$LD$LF\r\n/usr/bin/inxi -FGISZMxxxpu\r\n/usr/bin/inxi -FGISZMxxxpu >>$LD$LF\r\necho \" lsblk \"\r\necho \" lsblk \" >>$LD$LF\r\necho \"-------\" >>$LD$LF\r\nlsblk\r\nlsblk >>$LD$LF\r\necho \" gdisk /dev/sda \"\r\necho \" gdisk /dev/sda \" >>$LD$LF\r\necho \"----------------\" >>$LD$LF\r\ngdisk -l /dev/sda\r\ngdisk -l /dev/sda >>$LD$LF\r\necho \" parted /dev/sda \"\r\necho \" parted /dev/sda \" >>$LD$LF\r\nparted /dev/sda print\r\nparted /dev/sda print >>$LD$LF\r\necho \" gdisk /dev/sdb \"\r\necho \" gdisk /dev/sdb \" >>$LD$LF\r\necho \"----------------\" >>$LD$LF\r\ngdisk -l /dev/sdb\r\ngdisk -l /dev/sdb >>$LD$LF\r\necho \" parted /dev/sdb \"\r\necho \" parted /dev/sdb \" >>$LD$LF\r\necho \"----------------\" >>$LD$LF\r\nparted /dev/sdb print\r\nparted /dev/sdb print >>$LD$LF\r\necho \" blkid \"\r\necho \" blkid \" >>$LD$LF\r\necho \"-------\" >>$LD$LF\r\nblkid\r\nblkid >>$LD$LF\r\necho \" pvs \"\r\necho \" pvs \" >>$LD$LF\r\necho \"-----\" >>$LD$LF\r\npvs\r\npvs >>$LD$LF\r\necho \" vgs \"\r\necho \" vgs \" >>$LD$LF\r\necho \"-----\" >>$LD$LF\r\nvgs\r\nvgs >>$LD$LF\r\necho \" lvs \"\r\necho \" lvs \" >>$LD$LF\r\necho \"-----\" >>$LD$LF\r\nlvs\r\nlvs >>$LD$LF\r\nlvs -a -o +devices\r\nlvs -a -o +devices >>$LD$LF\r\necho \"eerste 2047 sectoren \"\r\necho \"eerste 2047 sectoren \" >>$LD$LF\r\necho \"---------------------\" >>$LD$LF\r\necho \"dd if=/dev/sda of=sda2047.mbr bs=512 count=2047\"\r\necho \"dd if=/dev/sda of=sda2047.mbr bs=512 count=2047\" >>$LD$LF\r\ndd if=/dev/sda of=/backup2/sda2047_${DATUM}.mbr bs=512 count=2047\r\necho \"dd if=/dev/sdb of=sdb2047.mbr bs=512 count=2047\"\r\necho \"dd if=/dev/sdb of=sdb2047.mbr bs=512 count=2047\" >>$LD$LF\r\ndd if=/dev/sdb of=/backup2/sdb2047_${DATUM}.mbr bs=512 count=2047\r\n\r\nsync\r\nRES=0\r\nexit $RES\r\n
\r\n\r\n", "db_count": 157 }, { "taaknaam": "Backup disk device settings van mijn Dell Inspiron op externe schijf /myssd2_data", "taaktext": "
\r\n#!/bin/bash\r\n# backup op myssd2_data\r\nLD=\"/myssd2_data/\"\r\nDATUM=\"$(date +%Y%m%d)\"\r\nLF=backupdisk_$(date +%Y%m%d).out\r\nRES=1\r\n# only run as root\r\nif [ \"$(id -u)\" != '0' ]\r\nthen\r\n echo \"Deze bash script moet opgestart worden met root rechten\"\r\n exit $RES\r\nfi\r\necho \"====== start backupdisk_sets ======\"\r\necho \"====== start backupdisk_sets ======\" >>$LD$LF\r\necho \"-----------------------------------\" >>$LD$LF\r\necho \" inxi \"\r\necho \" inxi \" >>$LD$LF\r\necho \"------\" >>$LD$LF\r\n/usr/bin/inxi -FGISZMxxxpu\r\n/usr/bin/inxi -FGISZMxxxpu >>$LD$LF\r\necho \" lsblk \"\r\necho \" lsblk \" >>$LD$LF\r\necho \"-------\" >>$LD$LF\r\nlsblk\r\nlsblk >>$LD$LF\r\necho \" gdisk /dev/sda \"\r\necho \" gdisk /dev/sda \" >>$LD$LF\r\necho \"----------------\" >>$LD$LF\r\ngdisk -l /dev/sda\r\ngdisk -l /dev/sda >>$LD$LF\r\necho \" parted /dev/sda \"\r\necho \" parted /dev/sda \" >>$LD$LF\r\nparted /dev/sda print\r\nparted /dev/sda print >>$LD$LF\r\necho \" gdisk /dev/sdb \"\r\necho \" gdisk /dev/sdb \" >>$LD$LF\r\necho \"----------------\" >>$LD$LF\r\ngdisk -l /dev/sdb\r\ngdisk -l /dev/sdb >>$LD$LF\r\necho \" parted /dev/sdb \"\r\necho \" parted /dev/sdb \" >>$LD$LF\r\necho \"----------------\" >>$LD$LF\r\nparted /dev/sdb print\r\nparted /dev/sdb print >>$LD$LF\r\necho \" blkid \"\r\necho \" blkid \" >>$LD$LF\r\necho \"-------\" >>$LD$LF\r\nblkid\r\nblkid >>$LD$LF\r\necho \" pvs \"\r\necho \" pvs \" >>$LD$LF\r\necho \"-----\" >>$LD$LF\r\npvs\r\npvs >>$LD$LF\r\necho \" vgs \"\r\necho \" vgs \" >>$LD$LF\r\necho \"-----\" >>$LD$LF\r\nvgs\r\nvgs >>$LD$LF\r\necho \" lvs \"\r\necho \" lvs \" >>$LD$LF\r\necho \"-----\" >>$LD$LF\r\nlvs\r\nlvs >>$LD$LF\r\nlvs -a -o +devices\r\nlvs -a -o +devices >>$LD$LF\r\necho \"eerste 2047 sectoren \"\r\necho \"eerste 2047 sectoren \" >>$LD$LF\r\necho \"---------------------\" >>$LD$LF\r\necho \"dd if=/dev/sda of=sda2047.mbr bs=512 count=2047\"\r\necho \"dd if=/dev/sda of=sda2047.mbr bs=512 count=2047\" >>$LD$LF\r\ndd if=/dev/sda of=/myssd2_data/sda2047_${DATUM}.mbr bs=512 count=2047\r\necho \"dd if=/dev/sdb of=sdb2047.mbr bs=512 count=2047\"\r\necho \"dd if=/dev/sdb of=sdb2047.mbr bs=512 count=2047\" >>$LD$LF\r\ndd if=/dev/sdb of=/myssd2_data/sdb2047_${DATUM}.mbr bs=512 count=2047\r\n# echo \"backup vgs\"\r\n# echo \"backup vgs\" >>$LD$LF\r\n# echo \"----------\" >>$LD$LF\r\n# echo \"dd if=/dev/mydell of=mydell.dd\"\r\n# echo \"dd if=/dev/mydell of=mydell.dd >>$LD$LF\r\n# dd if=/dev/mydell of=mydell_${DATUM}.dd\r\n# echo \"dd if=/dev/myssd of=myssd.dd\"\r\n# echo \"dd if=/dev/myssd of=myssd.dd >>$LD$LF\r\n# dd if=/dev/myssd of=myssd_${DATUM}.dd\r\nsync\r\nRES=0\r\nexit $RES\r\n
\r\n\r\n", "db_count": 160 }, { "taaknaam": "Backup van mijn Dell Inspiron op /backup2", "taaktext": "
\r\n#!/bin/bash\r\n# backup op /backup2\r\n# be sure you have at least 6G free on /dev/myssd !!\r\ngrootte=6G\r\ncompress=11\r\nthread=4\r\nfiles=1000\r\nLD=\"/backup2/\"\r\nDIR=\"dir.lst\"\r\nDIR2=\"dir2.lst\"\r\nDATUM=\"$(date +%Y%m%d)\"\r\nLF=backup_$(date +%Y%m%d).out\r\nRES=1\r\n# only run as root\r\nif [ \"$(id -u)\" != '0' ]\r\nthen\r\n echo \"Deze bash script moet opgestart worden met root rechten\"\r\n exit $RES\r\nfi\r\necho \"====== start backup ======\" >>$LD$LF\r\necho \"--------------------------\" >>$LD$LF\r\nrm $LD$DIR2 -v >>$LD$LF\r\ncp $LD$DIR $LD$DIR2 -v >>$LD$LF\r\n\r\nCHECKSDC=\"$(lsblk | grep sdc3)\"\r\nCHECKSDB=\"$(lsblk | grep sdb3)\"\r\nCHECKSDA=\"$(lsblk | grep sda3)\"\r\nif [ ! -z \"$CHECKSDA\" ]\r\nthen\r\n if echo \"$CHECKSDA\" | grep '464,3G'\r\n then\r\n SDX1=\"/dev/sda1\"\r\n SDX2=\"/dev/sda2\"\r\n fi\r\nfi\r\nif [ ! -z \"$CHECKSDB\" ]\r\nthen\r\n if echo \"$CHECKSDB\" | grep '464,3G'\r\n then\r\n SDX1=\"/dev/sdb1\"\r\n SDX2=\"/dev/sdb2\"\r\n fi\r\nfi\r\nif [ ! -z \"$CHECKSDC\" ]\r\nthen\r\n if echo \"$CHECKSDC\" | grep '464,3G'\r\n then\r\n SDX1=\"/dev/sdc1\"\r\n SDX2=\"/dev/sdc2\"\r\n fi\r\nfi\r\nRES=2\r\nif [ -z \"$SDX1\" ]\r\nthen\r\n cp $LD$DIR2 $LD$DIR -v >>$LD$LF\r\n echo \"exit bash script : RES = $RES\"\r\n exit $RES\r\nfi\r\n\r\n\r\ncd $LD\r\nTSEC=0\r\nSECONDS=0\r\n# backup boot no logical volume !\r\nbackup=$SDX1\r\nbackup1=/backup2/backup-boot\r\nTIMESTAMP=\"$(date +%Y%m%d-%Hh%M)\"\r\n# lees laatste lijn\r\nline=$(tail -n 1 $LD$DIR)\r\necho \"lijn : $line\"\r\necho \"datum : $DATUM\"\r\nif [ $line == $DATUM ]\r\nthen\r\n\tcp $LD$DIR2 $LD$DIR -v >>$LD$LF\r\n\techo \"deze backup is vandaag al eens gedaan !! Exit\"\r\n\texit $RES\r\nfi\r\necho $DATUM >>$LD$DIR\r\necho \"datum $DATUM toegevoegd in $DIR\"\r\necho \"datum $DATUM toegevoegd in $DIR\" >>$LD$LF\r\n# lees eerste lijn uit $DIR\r\nline=$(head -n 1 $LD$DIR)\r\necho \"line is $line\"\r\nif [ $line -ne $DATUM ]\r\nthen\r\n # verwijder alle backups gemaakt op datum $line\r\n rm -v $LD*$line* >>$LD$LF\r\n # verwijder de eerste lijn uit $DIR\r\n sed -i 1d $LD$DIR\r\n echo \"eerste lijn = $line is uit $LD$DIR\"\r\n echo \"eerste lijn = $line is uit $LD$DIR\" >>$LD$LF\r\nfi\r\necho \"backup \" $backup >>$LD$LF\r\necho \"TIMESTAMP \" $TIMESTAMP >>$LD$LF\r\ndf -h $LD >>$LD$LF\r\necho \" fsarchiver -A -Z $compress -s $files -j $thread savefs $backup1-$TIMESTAMP.fsa $backup\"\r\necho \" fsarchiver -A -Z $compress -s $files -j $thread savefs $backup1-$TIMESTAMP.fsa $backup\" >>$LD$LF\r\nfsarchiver -A -Z $compress -s $files -j $thread savefs $backup1-$TIMESTAMP.fsa $backup >>$LD$LF\r\nls $backup1-$TIMESTAMP.* -la >>$LD$LF\r\nELAPSED=\"Elapsed: $(($SECONDS / 3600))hrs $((($SECONDS / 60) % 60))min $(($SECONDS % 60))sec\"\r\necho \"duur = \" $ELAPSED\r\necho \"duur = \" $ELAPSED >>$LD$LF\r\nTSEC=$(($TSEC + $SECONDS))\r\ndf -h $LD >>$LD$LF\r\nSECONDS=0\r\nbackup=$SDX2\r\nbackup1=/backup2/backup-bootefi\r\nTIMESTAMP=\"$(date +%Y%m%d-%Hh%M)\"\r\necho \"backup \" $backup >>$LD$LF\r\necho \"TIMESTAMP \" $TIMESTAMP >>$LD$LF\r\necho \" fsarchiver -A -Z $compress -s $files -j $thread savefs $backup1-$TIMESTAMP.fsa $backup\"\r\necho \" fsarchiver -A -Z $compress -s $files -j $thread savefs $backup1-$TIMESTAMP.fsa $backup\" >>$LD$LF\r\nfsarchiver -A -Z $compress -s $files -j $thread savefs $backup1-$TIMESTAMP.fsa $backup >>$LD$LF\r\nls $backup1-$TIMESTAMP.* -la >>$LD$LF\r\nELAPSED=\"Elapsed: $(($SECONDS / 3600))hrs $((($SECONDS / 60) % 60))min $(($SECONDS % 60))sec\"\r\necho \"duur = \" $ELAPSED\r\necho \"duur = \" $ELAPSED >>$LD$LF\r\ndf -h $LD >>$LD$LF\r\nTSEC=$(($TSEC + $SECONDS))\r\nSECONDS=0\r\nbackup=/dev/mapper/myssd-root\r\nbackup1=/backup2/backup-root\r\nTIMESTAMP=\"$(date +%Y%m%d-%Hh%M)\"\r\necho \"backup \" $backup >>$LD$LF\r\necho \"TIMESTAMP \" $TIMESTAMP >>$LD$LF\r\necho \" lvcreate -L $grootte -s -n mysnap $backup \"\r\necho \" lvcreate -L $grootte -s -n mysnap $backup \" >>$LD$LF\r\nlvcreate -L $grootte -s -n mysnap $backup >>$LD$LF\r\necho \" fsarchiver -A -Z $compress -s $files -j $thread savefs $backup1-$TIMESTAMP.fsa /dev/mapper/myssd-mysnap\"\r\necho \" fsarchiver -A -Z $compress -s $files -j $thread savefs $backup1-$TIMESTAMP.fsa /dev/mapper/myssd-mysnap\" >>$LD$LF\r\nfsarchiver -A -Z $compress -s $files -j $thread savefs $backup1-$TIMESTAMP.fsa /dev/mapper/myssd-mysnap >>$LD$LF\r\necho \" lvremove -vf /dev/mapper/myssd-mysnap \"\r\necho \" lvremove -vf /dev/mapper/myssd-mysnap \" >>$LD$LF\r\nlvremove -vf /dev/mapper/myssd-mysnap >>$LD$LF\r\nls $backup1-$TIMESTAMP.* -la >>$LD$LF\r\nELAPSED=\"Elapsed: $(($SECONDS / 3600))hrs $((($SECONDS / 60) % 60))min $(($SECONDS % 60))sec\"\r\necho \"duur = \" $ELAPSED\r\necho \"duur = \" $ELAPSED >>$LD$LF\r\ndf -h $LD >>$LD$LF\r\nTSEC=$(($TSEC + $SECONDS))\r\nSECONDS=0\r\nbackup=/dev/mapper/myssd-home\r\nbackup1=/backup2/backup-home\r\nTIMESTAMP=\"$(date +%Y%m%d-%Hh%M)\"\r\necho \"backup \" $backup >>$LD$LF\r\necho \"TIMESTAMP \" $TIMESTAMP >>$LD$LF\r\necho \" lvcreate -L $grootte -s -n mysnap $backup \"\r\necho \" lvcreate -L $grootte -s -n mysnap $backup \" >>$LD$LF\r\nlvcreate -L $grootte -s -n mysnap $backup >>$LD$LF\r\necho \" fsarchiver -A -Z $compress -s $files -j $thread savefs $backup1-$TIMESTAMP.fsa /dev/mapper/myssd-mysnap\"\r\necho \" fsarchiver -A -Z $compress -s $files -j $thread savefs $backup1-$TIMESTAMP.fsa /dev/mapper/myssd-mysnap\" >>$LD$LF\r\nfsarchiver -A -Z $compress -s $files -j $thread savefs $backup1-$TIMESTAMP.fsa /dev/mapper/myssd-mysnap >>$LD$LF\r\necho \" lvremove -vf /dev/mapper/myssd-mysnap \"\r\necho \" lvremove -vf /dev/mapper/myssd-mysnap \" >>$LD$LF\r\nlvremove -vf /dev/mapper/myssd-mysnap >>$LD$LF\r\nls $backup1-$TIMESTAMP.* -la >>$LD$LF\r\nELAPSED=\"Elapsed: $(($SECONDS / 3600))hrs $((($SECONDS / 60) % 60))min $(($SECONDS % 60))sec\"\r\necho \"duur = \" $ELAPSED\r\necho \"duur = \" $ELAPSED >>$LD$LF\r\ndf -h $LD >>$LD$LF\r\nTSEC=$(($TSEC + $SECONDS))\r\nSECONDS=0\r\nbackup=/dev/mapper/myssd-data\r\nbackup1=/backup2/backup-data\r\nTIMESTAMP=\"$(date +%Y%m%d-%Hh%M)\"\r\necho \"backup \" $backup >>$LD$LF\r\necho \"TIMESTAMP \" $TIMESTAMP >>$LD$LF\r\necho \" lvcreate -L $grootte -s -n mysnap $backup \"\r\necho \" lvcreate -L $grootte -s -n mysnap $backup \" >>$LD$LF\r\nlvcreate -L $grootte -s -n mysnap $backup >>$LD$LF\r\necho \" fsarchiver -A -Z $compress -s $files -j $thread savefs $backup1-$TIMESTAMP.fsa /dev/mapper/myssd-mysnap\"\r\necho \" fsarchiver -A -Z $compress -s $files -j $thread savefs $backup1-$TIMESTAMP.fsa /dev/mapper/myssd-mysnap\" >>$LD$LF\r\nfsarchiver -A -Z $compress -s $files -j $thread savefs $backup1-$TIMESTAMP.fsa /dev/mapper/myssd-mysnap >>$LD$LF\r\necho \" lvremove -vf /dev/mapper/myssd-mysnap \"\r\necho \" lvremove -vf /dev/mapper/myssd-mysnap \" >>$LD$LF\r\nlvremove -vf /dev/mapper/myssd-mysnap >>$LD$LF\r\nls $backup1-$TIMESTAMP.* -la >>$LD$LF\r\nELAPSED=\"Elapsed: $(($SECONDS / 3600))hrs $((($SECONDS / 60) % 60))min $(($SECONDS % 60))sec\"\r\necho \"duur = \" $ELAPSED\r\necho \"duur = \" $ELAPSED >>$LD$LF\r\ndf -h $LD >>$LD$LF\r\nTSEC=$(($TSEC + $SECONDS))\r\nELAPSED=\"Elapsed: $(($TSEC / 3600))hrs $((($TSEC / 60) % 60))min $(($TSEC % 60))sec\"\r\necho \"totale duur = \" $ELAPSED\r\necho \"totale duur = \" $ELAPSED >>$LD$LF\r\ndf -h $LD >>$LD$LF\r\nTIMESTAMP=\"$(date +%Y%m%d-%Hh%M)\"\r\necho \"TIMESTAMP \" $TIMESTAMP >>$LD$LF\r\necho \"backup gedaan\" >>$LD$LF\r\necho \"-------------\" >>$LD$LF\r\nls *$DATUM* -la >>$LD$LF\r\necho \"====== end backup dell latitude ======\" >>$LD$LF\r\nsync\r\nRES=0\r\nexit $RES\r\n
\r\n\r\n", "db_count": 164 }, { "taaknaam": "Backup van mijn Dell Inspiron op externe SSD schijf\r\n/myssd2_data", "taaktext": "
\r\n#!/bin/bash\r\n# backup op /myssd2_data\r\n# be sure you have at least 6G free on /dev/myssd !!\r\ngrootte=6G\r\ncompress=11\r\nthread=4\r\nfiles=1000\r\nLD=\"/myssd2_data/\"\r\nDIR=\"dir.lst\"\r\nDIR2=\"dir2.lst\"\r\nDATUM=\"$(date +%Y%m%d)\"\r\nLF=backup_$(date +%Y%m%d).out\r\nRES=1\r\n# only run as root\r\nif [ \"$(id -u)\" != '0' ]\r\nthen\r\n echo \"Deze bash script moet opgestart worden met root rechten\"\r\n exit $RES\r\nfi\r\necho \"====== start backup ======\" >>$LD$LF\r\necho \"--------------------------\" >>$LD$LF\r\nrm $LD$DIR2 -v >>$LD$LF\r\ncp $LD$DIR $LD$DIR2 -v >>$LD$LF\r\n\r\nCHECKSDC=\"$(lsblk | grep sdc3)\"\r\nCHECKSDB=\"$(lsblk | grep sdb3)\"\r\nCHECKSDA=\"$(lsblk | grep sda3)\"\r\nif [ ! -z \"$CHECKSDA\" ]\r\nthen\r\n if echo \"$CHECKSDA\" | grep '464,3G'\r\n then\r\n SDX1=\"/dev/sda1\"\r\n SDX2=\"/dev/sda2\"\r\n fi\r\nfi\r\nif [ ! -z \"$CHECKSDB\" ]\r\nthen\r\n if echo \"$CHECKSDB\" | grep '464,3G'\r\n then\r\n SDX1=\"/dev/sdb1\"\r\n SDX2=\"/dev/sdb2\"\r\n fi\r\nfi\r\nif [ ! -z \"$CHECKSDC\" ]\r\nthen\r\n if echo \"$CHECKSDC\" | grep '464,3G'\r\n then\r\n SDX1=\"/dev/sdc1\"\r\n SDX2=\"/dev/sdc2\"\r\n fi\r\nfi\r\nRES=2\r\nif [ -z \"$SDX1\" ]\r\nthen\r\n cp $LD$DIR2 $LD$DIR -v >>$LD$LF\r\n echo \"exit bash script : RES = $RES\"\r\n exit $RES\r\nfi\r\n\r\ncd $LD\r\nTSEC=0\r\nSECONDS=0\r\n# backup boot no logical volume !\r\nbackup=$SDX1\r\nbackup1=/myssd2_data/backup-boot\r\nTIMESTAMP=\"$(date +%Y%m%d-%Hh%M)\"\r\n# lees laatste lijn\r\nline=$(tail -n 1 $LD$DIR)\r\necho \"lijn : $line\"\r\necho \"datum : $DATUM\"\r\nif [ $line == $DATUM ]\r\nthen\r\n\tcp $LD$DIR2 $LD$DIR -v >>$LD$LF\r\n\techo \"deze backup is vandaag al eens gedaan !! Exit\"\r\n\texit $RES\r\nfi\r\necho $DATUM >>$LD$DIR\r\necho \"datum $DATUM toegevoegd in $DIR\"\r\necho \"datum $DATUM toegevoegd in $DIR\" >>$LD$LF\r\n# lees eerste lijn uit $DIR\r\nline=$(head -n 1 $LD$DIR)\r\necho \"line is $line\"\r\nif [ $line -ne $DATUM ]\r\nthen\r\n # verwijder alle backups gemaakt op datum $line\r\n rm -v $LD*$line* >>$LD$LF\r\n # verwijder de eerste lijn uit $DIR\r\n sed -i 1d $LD$DIR\r\n echo \"eerste lijn = $line is uit $LD$DIR\"\r\n echo \"eerste lijn = $line is uit $LD$DIR\" >>$LD$LF\r\nfi\r\necho \"backup \" $backup >>$LD$LF\r\necho \"TIMESTAMP \" $TIMESTAMP >>$LD$LF\r\ndf -h $LD >>$LD$LF\r\necho \" fsarchiver -A -Z $compress -s $files -j $thread savefs $backup1-$TIMESTAMP.fsa $backup\"\r\necho \" fsarchiver -A -Z $compress -s $files -j $thread savefs $backup1-$TIMESTAMP.fsa $backup\" >>$LD$LF\r\nfsarchiver -A -Z $compress -s $files -j $thread savefs $backup1-$TIMESTAMP.fsa $backup >>$LD$LF\r\nls $backup1-$TIMESTAMP.* -la >>$LD$LF\r\nELAPSED=\"Elapsed: $(($SECONDS / 3600))hrs $((($SECONDS / 60) % 60))min $(($SECONDS % 60))sec\"\r\necho \"duur = \" $ELAPSED\r\necho \"duur = \" $ELAPSED >>$LD$LF\r\nTSEC=$(($TSEC + $SECONDS))\r\ndf -h $LD >>$LD$LF\r\nSECONDS=0\r\nbackup=$SDX2\r\nbackup1=/myssd2_data/backup-bootefi\r\nTIMESTAMP=\"$(date +%Y%m%d-%Hh%M)\"\r\necho \"backup \" $backup >>$LD$LF\r\necho \"TIMESTAMP \" $TIMESTAMP >>$LD$LF\r\necho \" fsarchiver -A -Z $compress -s $files -j $thread savefs $backup1-$TIMESTAMP.fsa $backup\"\r\necho \" fsarchiver -A -Z $compress -s $files -j $thread savefs $backup1-$TIMESTAMP.fsa $backup\" >>$LD$LF\r\nfsarchiver -A -Z $compress -s $files -j $thread savefs $backup1-$TIMESTAMP.fsa $backup >>$LD$LF\r\nls $backup1-$TIMESTAMP.* -la >>$LD$LF\r\nELAPSED=\"Elapsed: $(($SECONDS / 3600))hrs $((($SECONDS / 60) % 60))min $(($SECONDS % 60))sec\"\r\necho \"duur = \" $ELAPSED\r\necho \"duur = \" $ELAPSED >>$LD$LF\r\ndf -h $LD >>$LD$LF\r\nTSEC=$(($TSEC + $SECONDS))\r\nSECONDS=0\r\nbackup=/dev/mapper/myssd-root\r\nbackup1=/myssd2_data/backup-root\r\nTIMESTAMP=\"$(date +%Y%m%d-%Hh%M)\"\r\necho \"backup \" $backup >>$LD$LF\r\necho \"TIMESTAMP \" $TIMESTAMP >>$LD$LF\r\necho \" lvcreate -L $grootte -s -n mysnap $backup \"\r\necho \" lvcreate -L $grootte -s -n mysnap $backup \" >>$LD$LF\r\nlvcreate -L $grootte -s -n mysnap $backup >>$LD$LF\r\necho \" fsarchiver -A -Z $compress -s $files -j $thread savefs $backup1-$TIMESTAMP.fsa /dev/mapper/myssd-mysnap\"\r\necho \" fsarchiver -A -Z $compress -s $files -j $thread savefs $backup1-$TIMESTAMP.fsa /dev/mapper/myssd-mysnap\" >>$LD$LF\r\nfsarchiver -A -Z $compress -s $files -j $thread savefs $backup1-$TIMESTAMP.fsa /dev/mapper/myssd-mysnap >>$LD$LF\r\necho \" lvremove -vf /dev/mapper/myssd-mysnap \"\r\necho \" lvremove -vf /dev/mapper/myssd-mysnap \" >>$LD$LF\r\nlvremove -vf /dev/mapper/myssd-mysnap >>$LD$LF\r\nls $backup1-$TIMESTAMP.* -la >>$LD$LF\r\nELAPSED=\"Elapsed: $(($SECONDS / 3600))hrs $((($SECONDS / 60) % 60))min $(($SECONDS % 60))sec\"\r\necho \"duur = \" $ELAPSED\r\necho \"duur = \" $ELAPSED >>$LD$LF\r\ndf -h $LD >>$LD$LF\r\nTSEC=$(($TSEC + $SECONDS))\r\nSECONDS=0\r\nbackup=/dev/mapper/myssd-home\r\nbackup1=/myssd2_data/backup-home\r\nTIMESTAMP=\"$(date +%Y%m%d-%Hh%M)\"\r\necho \"backup \" $backup >>$LD$LF\r\necho \"TIMESTAMP \" $TIMESTAMP >>$LD$LF\r\necho \" lvcreate -L $grootte -s -n mysnap $backup \"\r\necho \" lvcreate -L $grootte -s -n mysnap $backup \" >>$LD$LF\r\nlvcreate -L $grootte -s -n mysnap $backup >>$LD$LF\r\necho \" fsarchiver -A -Z $compress -s $files -j $thread savefs $backup1-$TIMESTAMP.fsa /dev/mapper/myssd-mysnap\"\r\necho \" fsarchiver -A -Z $compress -s $files -j $thread savefs $backup1-$TIMESTAMP.fsa /dev/mapper/myssd-mysnap\" >>$LD$LF\r\nfsarchiver -A -Z $compress -s $files -j $thread savefs $backup1-$TIMESTAMP.fsa /dev/mapper/myssd-mysnap >>$LD$LF\r\necho \" lvremove -vf /dev/mapper/myssd-mysnap \"\r\necho \" lvremove -vf /dev/mapper/myssd-mysnap \" >>$LD$LF\r\nlvremove -vf /dev/mapper/myssd-mysnap >>$LD$LF\r\nls $backup1-$TIMESTAMP.* -la >>$LD$LF\r\nELAPSED=\"Elapsed: $(($SECONDS / 3600))hrs $((($SECONDS / 60) % 60))min $(($SECONDS % 60))sec\"\r\necho \"duur = \" $ELAPSED\r\necho \"duur = \" $ELAPSED >>$LD$LF\r\ndf -h $LD >>$LD$LF\r\nTSEC=$(($TSEC + $SECONDS))\r\nSECONDS=0\r\nbackup=/dev/mapper/myssd-data\r\nbackup1=/myssd2_data/backup-data\r\nTIMESTAMP=\"$(date +%Y%m%d-%Hh%M)\"\r\necho \"backup \" $backup >>$LD$LF\r\necho \"TIMESTAMP \" $TIMESTAMP >>$LD$LF\r\necho \" lvcreate -L $grootte -s -n mysnap $backup \"\r\necho \" lvcreate -L $grootte -s -n mysnap $backup \" >>$LD$LF\r\nlvcreate -L $grootte -s -n mysnap $backup >>$LD$LF\r\necho \" fsarchiver -A -Z $compress -s $files -j $thread savefs $backup1-$TIMESTAMP.fsa /dev/mapper/myssd-mysnap\"\r\necho \" fsarchiver -A -Z $compress -s $files -j $thread savefs $backup1-$TIMESTAMP.fsa /dev/mapper/myssd-mysnap\" >>$LD$LF\r\nfsarchiver -A -Z $compress -s $files -j $thread savefs $backup1-$TIMESTAMP.fsa /dev/mapper/myssd-mysnap >>$LD$LF\r\necho \" lvremove -vf /dev/mapper/myssd-mysnap \"\r\necho \" lvremove -vf /dev/mapper/myssd-mysnap \" >>$LD$LF\r\nlvremove -vf /dev/mapper/myssd-mysnap >>$LD$LF\r\nls $backup1-$TIMESTAMP.* -la >>$LD$LF\r\nELAPSED=\"Elapsed: $(($SECONDS / 3600))hrs $((($SECONDS / 60) % 60))min $(($SECONDS % 60))sec\"\r\necho \"duur = \" $ELAPSED\r\necho \"duur = \" $ELAPSED >>$LD$LF\r\ndf -h $LD >>$LD$LF\r\nTSEC=$(($TSEC + $SECONDS))\r\nELAPSED=\"Elapsed: $(($TSEC / 3600))hrs $((($TSEC / 60) % 60))min $(($TSEC % 60))sec\"\r\necho \"totale duur = \" $ELAPSED\r\necho \"totale duur = \" $ELAPSED >>$LD$LF\r\ndf -h $LD >>$LD$LF\r\nTIMESTAMP=\"$(date +%Y%m%d-%Hh%M)\"\r\necho \"TIMESTAMP \" $TIMESTAMP >>$LD$LF\r\necho \"backup gedaan\" >>$LD$LF\r\necho \"-------------\" >>$LD$LF\r\nls *$DATUM* -la >>$LD$LF\r\necho \"====== end backup dell latitude ======\" >>$LD$LF\r\nsync\r\nRES=0\r\nexit $RES\r\n
\r\n", "db_count": 169 }, { "taaknaam": "Budget_Beheer", "taaktext": "
titel: "Budget_Beheer"
\r\n\r\nbeschrijving: "bootloader van systemd"
\r\n\r\ncategoriën:
\r\n\r\n\r\ndocker pull ulefr01/budget:latest
\r\n\r\n# maak dat poort 80 vrij is ; sudo systemctl stop apache2.service\r\ndocker run -p 80:80 ulefr01/budget
\r\nNoot:
\r\n\r\n\r\ndocker run -it -p 80:80 budget /usr/bin/fish
\r\nDient om een nieuwe transactie te maken
\r\n\r\nOp ieder rij kun je iedere transactie aanpassen en/of wegdoen door op het 'Idnummer' te klikken.
\r\n\r\nOp de Rekeningen Lijst kun je de laatste totalen zien per Rekening.
\r\n\r\nOp de Rekeningen Lijst kun je door op het Id te drukken de Rekening aanpassen en/of zelfs wegdoen.
\r\n\r\nexporteer database naar json bestanden
\r\n\r\n\r\n./manage.py run_export
\r\n\r\n/usr/xptracker/xptracker\r\nFunction : rekeningen_list\r\nNumber of Queries : 55\r\nFinished in : 0.04s\r\nFunction : transacties_list\r\nNumber of Queries : 1384\r\nFinished in : 0.80s\r\nFunction : users_list\r\nNumber of Queries : 1\r\nFinished in : 0.00s
\r\n\r\n./manage.py uitvoer_json_txt
\r\n\r\n/usr/xptracker/xptracker\r\njq . rekeningen_list.json >rekeningen_list.txt\r\njq . transacties_list.json >transacties_list.txt\r\njq . users_list.json >users_list.txt\r\n-rw-r--r-- 1 root root 10058 Sep 24 20:06 rekeningen_list.txt\r\n-rw-r--r-- 1 root root 915 Mar 18 2022 requirements.txt\r\n-rw-r--r-- 1 root root 7513 Mar 18 2022 show_urls.txt\r\n-rw-rw-r-- 1 root root 119766 Sep 24 20:06 transacties_list.txt\r\n-rw-rw-r-- 1 root root 403 Sep 24 20:06 users_list.txt
\r\n\r\n./manage.py init_items
\r\n\r\n/usr/xptracker/xptracker\r\ndelete.sql is uitgevoerd\r\nset_sequence_0.sql is uitgevoerd
\r\nimporteer gegevens vanaf json bestanden
\r\n\r\n\r\n./manage.py run_import
\r\n\r\n/usr/xptracker/xptracker
\r\nDownload Sql database db.sqlite3 op ~/Downloads/db.sqlite3
\r\n\r\n\tcheck het container id (=je_id) van je docker containers
\r\n\t\r\n #/bin/bash\r\n # wijzig 'je_id' naar je docker container_id\r\n docker cp 'je_id':/usr/xptracker/xptracker/db.sqlite3 . \r\n echo "downld db.sqlite3 op container je_id gedaan"\r\n exit 0
\r\n\r\n sqlitebrowser db.sqlite3
\r\n\r\n #/bin/bash\r\n docker cp ~/Downloads/db.sqlite3 'nieuw_id':/usr/xptracker/xptracker/. \r\n echo "copy db.sqlite3 op container nieuw_id06 gedaan"\r\n rm ~/Downloads/db.sqlite3 -v\r\n exit 0
\r\nJe kan je opmerkingen kwijt op mijn email adres : franz.ulenaers@telenet.be
\r\n", "db_count": 101 }, { "taaknaam": "Cryfs heropmaken", "taaktext": "
\r\n\r\n\r\nmkdir /data/Decrypt2 /data/Encrypt2
\r\n\r\ncryfs /data/Encrypt2 /data/Decrypt2
\r\n\r\n
\r\n fill in password 2x zie Bitwarden
\r\n
\r\ncp -rv /data/Decrypt/* /data/Decrypt2/
\r\ncp -rv /data/Decrypt/.* /data/Decrypt2/fusermount -u /data/Decrypt
\r\n\r\nmv /data/Encrypt /data/Encrypt3
\r\n\r\nmkdir /data/Encrypt /data/Decrypt
\r\n\r\n( chown ulefr01:ulefr01 /data/Decrypt )
\r\n\r\n\r\n\r\n
\r\ncryfs /data/Encrypt /data/Decrypt
\r\n fill in password 2x zie bitwardencp -rv /data/Decrypt2/* /data/Decrypt/
\r\n\r\n
\r\ncp -rv /data/Decrypt2/.* /data/Decrypt/cryfs-unmount /data/Decrypt2
\r\n\r\ncryfs-unmount /data/Decrypt
\r\n\r\nrmdir /data/Decrypt2
\r\n
\r\nrm -rv /data/Encrypt2/
\r\n\r\n\r\ncryfs-automount cryfsauto -b /data/Encrypt -m /data/Decrypt -p hetwachtwoord
\r\n\r\n\r\n
reboot
\r\n
\r\n\r\n\r\nrm -r /data/Decrypt
\r\n\r\nmkdir /data/Decrypt
\r\n\r\ncryfs /data/Encrypt /data/Decrypt
\r\n\r\nvul in 2x paswoord
\r\n\r\nbij problemen :
\r\n\r\nrm -r /data/Decrypt/
\r\n\r\nmkdir /data/Decrypt
\r\n\r\ncryfs /data/Encrypt /data/Decrypt
\r\n\r\n\r\n
", "db_count": 140 }, { "taaknaam": "Django Tips", "taaktext": "
Here we go:
\r\n\r\nIt is generally recommended to use singular nouns for model naming, for example: User, Post, Article. That is, the last component of the name should be a noun, e.g.: Some New Shiny Item. It is correct to use singular numbers when one unit of a model does not contain information about several objects.
\r\n\r\nFor relationships such as ForeignKey, OneToOneKey, ManyToMany it is sometimes better to specify a name. Imagine there is a model called Article, - in which one of the relationships is ForeignKey for model User. If this field contains information about the author of the article, then author will be a more appropriate name than user.
\r\n\r\nIt is reasonable to indicate a related-name in plural as related-name addressing returns queryset. Please, do set adequate related-names. In the majority of cases, the name of the model in plural will be just right. For example:
\r\n\r\nclass Owner(models.Model):
\r\n\r\npass
\r\n\r\nclass Item(models.Model):
\r\n\r\nowner = models.ForeignKey(Owner, related_name='items')
\r\n\r\nThere is no point in using ForeignKey with unique=Trueas there exists OneToOneField for such cases.
\r\n\r\nPreferable attributes and methods order in a model (an empty string between the points).
\r\n\r\nconstants (for choices and other)
\r\nfields of the model
\r\ncustom manager indication
\r\nmeta
\r\ndef unicode (python 2) or def str (python 3)
\r\nother special methods
\r\ndef clean
\r\ndef save
\r\ndef get_absolut_url
\r\nother methods
\r\nPlease note that the given order was taken from documentations and slightly expanded.
If you need to add a model, then, having created a class of a model, execute serially manage.py commands makemigrations and migrate (or use South for Django 1.6 and below).
\r\n\r\nYou should not allow thoughtless use of denormalization in relational databases. Always try to avoid it, except for the cases when you denormalise data consciously for whatever the reason may be (e.g. productivity). If at the stage of database designing you understand that you need to denormalise much of the data, a good option could be the use of NoSQL. However, if most of data does not require denormalisation, which cannot be avoided, think about a relational base with JsonField to store some data.
\r\n\r\nDo not use null=True or blank=True for BooleanField. It should also be pointed out that it is better to specify default values for such fields. If you realise that the field can remain empty, you need NullBooleanField.
\r\n\r\nThe best place to allocate business logic for your project is in models, namely method models and model manager. It is possible that method models can only provoke some methods/functions. If it is inconvenient or impossible to allocate logic in models, you need to replace its forms or serializers in tasks.
\r\n\r\nDo not duplicate model fields in ModelForm or ModelSerializer without need. If you want to specify that the form uses all model fields, use MetaFields. If you need to redefine a widget for a field with nothing else to be changed in this field, make use of Meta widgets to indicate widgets.
\r\n\r\nUsing ModelName.DoesNotExist instead of ObjectDoesNotExist makes your exception intercepting more specialised, which is a positive practice.
\r\n\r\nWhile using choices, it is recommended to:
\r\n\r\nkeep strings instead of numbers in the database (although this is not the best option from the point of optional database use, it is more convenient in practise as strings are more demonstrable, which allows the use of clear filters with get options from the box in REST frameworks).
\r\nvariables for variants storage are constants. That is why they must be indicated in uppercase.
\r\nindicate the variants before the fields lists.
\r\nif it is a list of the statuses, indicate it in chronological order (e.g. new, in_progress, completed).
\r\nyou can use Choices from the model_utils library. Take model Article, for instance:
\r\nfrom model_utils import Choices
class Article(models.Model):
\r\n\r\nSTATUSES = Choices(
\r\n\r\n(0, 'draft', _('draft')),
\r\n(1, 'published', _('published')) )
status = models.IntegerField(choices=STATUSES, default=STATUSES.draft)
\r\n…
\r\n\r\n
Using ORM, do not add an extra method call all before filter(), count(), etc.
\r\n\r\nIf it is justified, replace several BooleanFields with one field, status-like. e.g.
\r\n\r\nclass Article(models.Model):
\r\n\r\nis_published = models.BooleanField(default=False)
\r\nis_verified = models.BooleanField(default=False)
\r\n…
Assume the logic of our application presupposes that the article is not published and checked initially, then it is checked and marked is_verified in True and then it is published. You can notice that article cannot be published without being checked. So there are 3 conditions in total, but with 2 boolean fields we do not have 4 possible variants, and you should make sure there are no articles with wrong boolean fields conditions combinations. That is why using one status field instead of two boolean fields is a better option:
\r\n\r\n\r\n\r\n
class Article(models.Model):
\r\n\r\nSTATUSES = Choices('new', 'verified', 'published')
\r\n\r\n\r\n\r\n
\r\n\r\n
status = models.IntegerField(choices=STATUSES, default=STATUSES.draft)
\r\n…
This example may not be very illustrative, but imagine that you have 3 or more such boolean fields in your model, and validation control for these field value combinations can be really tiresome.
\r\n\r\n\r\n\r\n
Do not add model names to fields if there is no need to do so, e.g. if table User has a field user_status - you should rename the field into status, as long as there are no other statuses in this model.
\r\n\r\nAlways use PositiveIntegerField instead of IntegerField if it is not senseless, because “bad” data must not go to the base. For the same reason you should always use unique,unique_together for logically unique data and never use required=False in every field.
\r\n\r\nYou can use ModelName.objects.earliest('created'/'earliest') instead of order_by('created')[0] and you can also put get_latest_by in Meta model. You should keep in mind that latest/earliest as well as get can cause an exception DoesNotExist. Therefore, order_by('created').first() is the most useful variant.
\r\n\r\nDo not use len to get queryset’s objects amount. The count method can be used for this purpose. Like this: len(ModelName.objects.all()), firstly the query for selecting all data from the table will be carried out, then this data will be transformed into a Python object, and the length of this object will be found with the help of len. It is highly recommended not to use this method as count will address to a corresponding SQL function COUNT(). With count, an easier query will be carried out in that database and fewer resources will be required for python code performance.
\r\n\r\nDo not use queryset as a boolean value: instead of if queryset: do something use if queryset.exists(): do something. Remember, that querysets are lazy, and if you use queryset as a boolean value, an inappropriate query to a database will be carried out.
\r\n\r\nUsing model help_text in fields as a part of documentation will definitely facilitate the understanding of the data structure by you, your colleagues, and admin users.
\r\n\r\nDo not use FloatField to store information about the quantity of money. Instead, use DecimalField for this purpose. You can also keep this information in cents, units, etc.
\r\n\r\nnull=True - Allows column to keep null value.
\r\n\r\nblank=True - Will be used only if Forms for validation and not related to the database.
\r\n\r\nIn text-based fields, it's better to keep default value.
\r\n\r\nblank=True
\r\n\r\ndefault=''
\r\n\r\nThis way you'll get only one possible value for columns without data.
\r\n\r\nDo not add _id suffix to ForeignKeyField and OneToOneField.
\r\n\r\nIn all non abstract models, add methods unicode(python 2) or str(python 3). These methods must always return strings.
\r\n\r\nDo not use Meta.exclude for a model’s fields list description in ModelForm. It is better to use Meta.fields for this as it makes the fields list transparent. Do not use Meta.fields=”all” for the same reason.
\r\n\r\nSometimes even a separate folder for each FileField will not be enough if a large amount of downloaded files is expected. Storing many files in one folder means the file system will search for the needed file more slowly. To avoid such problems, you can do the following:
\r\n\r\ndef get_upload_path(instance, filename):
\r\n\r\nreturn os.path.join('account/avatars/', now().date().strftime("%Y/%m/%d"), filename)
\r\n\r\n\r\n\r\n
class User(AbstractUser):
\r\n\r\navatar = models.ImageField(blank=True, upload_to=get_upload_path)
\r\n\r\n\r\n\r\n
If you want to share some logic between models, you can use abstract models.
\r\n\r\nclass CreatedatModel(models.Model):
\r\n\r\ncreated_at = models.DateTimeField(
\r\n\r\nverbose_name=u"Created at",
\r\n\r\nauto_now_add=True
\r\n\r\n)
\r\n\r\nclass Meta:
\r\n\r\nabstract = True
\r\n\r\nclass Post(CreatedatModel):
\r\n\r\n...
\r\n\r\nclass Comment(CreatedatModel):
\r\n\r\n...
\r\n\r\nThe bigger project you work on, the more you repeat the same code in different places.
\r\n\r\nTo keep your code DRY and allocate business logic in models, you can use custom Managers and Queryset.
\r\n\r\nFor example. If you need to get comments count for posts, from the example above.
\r\n\r\nclass CustomManager(models.Manager):
\r\n\r\ndef with_comments_counter(self):
\r\n\r\nreturn self.get_queryset().annotate(comments_count=Count('comment_set'))
\r\n\r\nNow you can use:
\r\n\r\n\r\n\r\n
posts = Post.objects.with_comments_counter()
\r\n\r\nposts[0].comments_count
\r\n\r\nIf you want to use this method in chain with others queryset methods,
\r\n\r\nyou should use custom QuerySet:
\r\n\r\nclass CustomQuerySet(models.query.QuerySet):
\r\n\r\n"""Substitution the QuerySet, and adding additional methods to QuerySet
\r\n\r\n"""
\r\n\r\ndef with_comments_counter(self):
\r\n\r\n"""
\r\n\r\nAdds comments counter to queryset
\r\n\r\n"""
\r\n\r\nreturn self.annotate(comments_count=Count('comment_set'))
\r\n\r\nNow you can use:
\r\n\r\nposts = Post.objects.filter(...).with_comments_counter()
\r\n\r\nposts[0].comments_count
", "db_count": 133 }, { "taaknaam": "Django starten nieuw(bestaand) project", "taaktext": "bij gebruik van de fish shell
\r\n\r\neenmalig : installeer vf (virtualfish)
\r\n\r\n\r\n\r\n\r\nsudo pip install virtualfish
\r\n
eenmalig : creeer de functie : fish_prompt.fish
\r\n\r\n~/.config/fish/functions/fish_prompt.fish
\r\n\r\n\r\n\r\n\r\nif set -q VIRTUAL_ENV
\r\n\r\necho -n -s (set color -b blue white) "(" (basename "$VIRTUAL_ENV") ")" (set color normal) " "
\r\n\r\nend
\r\n
\r\n\r\n\r\nvf opties :
\r\n\r\nUsage: vf <command> [<args>]
\r\n\r\nAvailable commands:
\r\n\r\nactivate Activate a virtualenv
\r\n
\r\n addpath Adds a path to sys.path in this virtualenv
\r\n addplugins Install one or more plugins
\r\n all Run a command in all virtualenvs sequentially
\r\n cd Change directory to this virtualenv
\r\n cdpackages Change to the site-packages directory of this virtualenv
\r\n cdproject Change working directory to project directory
\r\n connect Connect this virtualenv to the current directory
\r\n deactivate Deactivate this virtualenv
\r\n environment Edit the environment variables for the active virtual environment
\r\n globalpackages Manage global site packages
\r\n help Print VirtualFish usage information
\r\n install Install VirtualFish
\r\n ls List all available virtual environments
\r\n lsprojects List projects
\r\n new Create a new virtualenv
\r\n project Create a new project and virtualenv with the name provided
\r\n rm Delete one or more virtual environments
\r\n rmplugins Remove one or more plugins
\r\n tmp Create a virtualenv that will be removed when deactivated
\r\n uninstall Uninstall VirtualFish
\r\n upgrade Upgrade virtualenv(s) to newer Python version
\r\n workon Work on a project
\r\n
andere tools kunnen ook gebruikt worden zoals :
\r\n\r\npipenv
\r\n\r\nmkvirtualenv
\r\n\r\n....
\r\n\r\nmijn_project_naam | \r\n\t\t\tfoldernaam van het project | \r\n\t\t
django_project_naam | \r\n\t\t\tbevat normaal db.sqlite3, settings, media, static, log en templates mappen | \r\n\t\t
bijkomende_app_naam | \r\n\t\t\teen project kan verschillende apps hebben | \r\n\t\t
\r\n\r\n\r\nmkdir /data/mijn_project_naam
\r\n
\r\ncd /data/mijn_project_naam
\r\natom ./
maak gebruik van een django template : hier maak ik gebruik van mijn eigen gemaakte template django-project-template uit mijn Downloads map
\r\n\r\n\r\n\r\n\r\ndjango-admin startproject --template ~/Downloads/django-project-template django_project_naam .
\r\n
creatie van een nieuwe virtuele omgeving voor je django project
\r\n\r\n\r\n\r\n\r\nvf new env_django_project_naam -p python3.8
\r\n
activeer je virtuele omgeving (eenmalig ofwel volledig buitem atom ofwel volledig binnen atom)
\r\n\r\n\r\n\r\n\r\nvf activate env_django_project_naam
\r\n
\r\n\r\n
installeer reeks python pakketten uit bestand = requirements.txt (eenmalig)
\r\n\r\n\r\n\r\n\r\npip install -r requirements.txt
\r\n
\r\n installeer indien nodig bijkomende pakket xyz
\r\n\r\n\r\npip install xyz
\r\n
bepalen welke pakketten in je virtuele omgeving geinstalleerd zijn :
\r\n\r\n\r\n\r\n\r\npip freeze
\r\n
al je geinstalleerde pakketten onthouden
\r\n\r\n\r\n\r\n\r\npip freeze >requirements.txt
\r\n
\r\n\r\n\r\n./manage.py migrate
\r\n
\r\n./manage.py createsuperuser
\r\n./manage.py runserver / runserver_plus
voor iedere bijkomende app
\r\n\r\n\r\n\r\n\r\n./manage-py startapp bijkomende_app_naam
\r\n
\r\n als app komt van een bestaande django site (na download zip naar /data/tmp/ en unzip)
maak gebruik van bash procedures : ../tmp/project_accounts , ../tmp/project_app , ../tmp/project_media , ../tmp/project_static , ../tmp/project_templates
\r\n\r\n\r\n\r\n\r\n.. / tmp / project_app mijn_project_naam app_naam .
\r\n
\r\n.. / tmp / project_app mijn_project_naam base .
settings/base.py
\r\n\r\n\r\n\r\n\r\nINSTALLED_APPS = [
\r\n\r\n'app_naam' ,
\r\n\r\n]
\r\n
starten website
\r\n\r\n\r\n\r\n\r\n./manage-py makemigrations
\r\n
(pas .... initial.py aan als volgorde veldnamen in de modellen gewijzigd is ; dit om problemen bij oplading gegevens te vermijden)
\r\n\r\n\r\n\r\n\r\n./manage-py migrate
\r\n
\r\n./manage-py runserver
\r\n sitemaps ?
\r\n als bestaande media , static en templates moet overgenomen worden
\r\n\r\n\r\n../tmp/ project_media site_project_naam mijn_project_naam .
\r\n
\r\n../tmp/ project_static site_project_naam mijn_project_naam .
\r\n../tmp/ project_templates site_project_naam mijn_project_naam .
\r\n\r\n\r\n./manage-py runserver_plus
\r\n
\r\n\r\n
\r\n\r\n\r\n./manage-py show_urls
\r\n
\r\n./manage-py shell_plus -ipython
\r\n./manage-py shell_plus -bpython
\r\n./manage-py graph_models auth -o auth.png
\r\n./manage-py graph_models app -o app.png
\r\n./manage-py graph_models -a -o all.png
\r\n./manage-py findstatic --verbosity 2 land/bootstrap/css/bootstrap.min.css
\r\n./manage-py find_template registration/password_reset_form.html
\r\n./manage-py collectstatic
\r\n./manage-py ping_google sitemap.xml
app_naam/management/commands map
\r\n\r\nexporteer
\r\n\r\n\r\n\r\n\r\n./manage.py run_export
\r\n
initializeer
\r\n\r\n\r\n\r\n\r\n./manage.py init_items
\r\n
importeer
\r\n\r\n\r\n\r\n\r\n./manage.py run_import
\r\n
init_items.py kan ook sql statements uitvoeren
\r\n\r\n\r\n\r\n
deactiveer virtuele omgeving
\r\n\r\n\r\n\r\n\r\nvf deactivate
\r\n
ping_google
\r\n\r\n\r\n\r\n\r\n./manage.py ping_google sitemap.xml
\r\n
\r\n\r\n
google search console
\r\n\r\ngoogle analytics
\r\n\r\n", "db_count": 114 }, { "taaknaam": "Fstab Dell Inspiron 15 5559", "taaktext": "
# /etc/fstab: static file system information.
\r\n#
\r\n# Use 'blkid' to print the universally unique identifier for a
\r\n# device; this may be used with UUID= as a more robust way to name devices
\r\n# that works even if disks are added and removed. See fstab(5).
\r\n#
\r\n# systemd generates mount units based on this file, see systemd.mount(5).
\r\n# Please run 'systemctl daemon-reload' after making changes here.
\r\n#
\r\n# <file system> <mount point> <type> <options> <dump> <pass>
\r\n# /dev/mapper/myssd-root / ext4 errors=remount-ro 0 1
\r\nUUID="0d8f82d3-9635-4e9c-8f6e-1512f4e1b2d6" / ext4 discard,noatime,data=writeback,commit=60,errors=remount-ro 0 1
\r\n# /boot was on /dev/sda1 during installation
\r\nUUID=76eff931-f5b2-4593-915f-d8b22e26b675 /boot ext4 defaults,noatime,data=writeback,commit=60 0 2
\r\n# /boot/efi was on /dev/sda2 during installation
\r\nUUID=375C-2F09 /boot/efi vfat umask=0077 0 1
\r\n# /dev/mapper/myssd-data /data ext4 discard,noatime,nodiratime 0 2
\r\nUUID="2c66bdba-e26c-401d-bf8c-dc304db8b2f2" /data ext4 discard,noatime,data=writeback,commit=60 0 2
\r\n# /dev/mapper/myssd-home /home ext4 discard,noatime,nodiratime 0 2
\r\nUUID="2b855259-d2e5-401a-a208-d7d6becaa566" /home ext4 discard,noatime,data=writeback,commit=60 0 2
\r\n#
\r\n# /dev/mapper/mydell-backup /backup ext4 noauto,user,noatime 0 2
\r\nUUID=f121a365-44da-46f1-bd6e-eed4f26109fe /backup ext4 user,noatime,data=writeback,commit=60,exec 0 2
\r\n/backup/swapfile none swap sw,discard 0 0
\r\n# /dev/mapper/mydell-backup2 /backup2 ext4 noauto,user,noatime 0 2
\r\nUUID=bc41856b-bace-4235-9e9e-ee49ffb83ea8 /backup2 ext4 noauto,user,noatime,data=writeback,commit=600,exec 0 0
\r\n/dev/sr0 /media/cdrom0 udf,iso9660 user,noauto 0 0
\r\n# binds
\r\n/data /home/ulefr01/data none bind
\r\n#
\r\n# /dev/sdb1 is oude /boot/efi
\r\n# /dev/sdb3 /media/ulefr01/WinC ntfs-3g noauto,user,umask=000,relatime 0 0
\r\n# mount als user werkt niet zelfs met setfacl op ulefr01 van /media/ulefr01 !
\r\nUUID=C4BE2937BE292400 /media/ulefr01/WinC ntfs-3g noauto,rw,exec,umask=000,relatime 0 0
\r\n# /dev/sdb4 /media/ulefr01/WinD ntfs-3g noauto,user,umask=000,relatime 0 0
\r\nUUID=E6DCB388DCB35193 /media/ulefr01/WinD ntfs-3g noauto,rw,exec,umask=000,relatime 0 0
\r\n# /dev/sdb5 /media/ulefr01/WinE ntfs-3g noauto,user,umask=000,relatime 0 0
\r\nUUID=B204B41404B3D995 /media/ulefr01/WinE ntfs-3g noauto,rw,exec,umask=000,relatime 0 0
\r\n# /dev/mapper/myssd-swap none swap sw 0 0
\r\n#
\r\nUUID=4D0E-9011 /stick16GB vfat noauto,user,noatime 0 0
\r\n#
\r\nUUID=349dd629-7fb7-41bc-9e5e-eef9f0f514a8 /stick32GB ext4 noauto,user,noatime,exec 0 0
\r\nUUID=51FE-C5FC /myssd2_EFI vfat noauto,user,noatime 0 0
\r\nUUID="a59547f3-adf3-4dae-9646-ba6ddd560ce4" /myssd2_data2 ext4 noauto,user,noatime,data=writeback,commit=600,exec 0 0
\r\nUUID="90b9bdd6-2458-43a0-8000-de9bf96e4a38" /myssd2_data ext4 noauto,user,noatime,data=writeback,commit=600,exec 0 0
\r\nUUID=69D2-B18A /myexthd1_EFI vfat noauto,user,noatime 0 0
\r\nUUID=db73a007-0730-4ef0-9ce2-1bba24039987 /myexthd1_2 ext4 noauto,user,noatime,exec 0 0
\r\nUUID=abc6cedf-ca7d-4748-ad7d-3a6f768cb0c5 /myexthd1_3 ext4 noauto,user,noatime,exec 0 0
\r\nUUID=9b3cc369-7d43-4d6f-8a87-936c404080bd /myexthd1_4 ext4 noauto,user,noatime,exec 0 0
\r\nUUID="a491343c-6d60-4941-b4f4-9d5697bf6cfe" /stick64GB ext4 noauto,user,noatime 0 0
\r\n#
\r\n
\r\n# /etc/fstab: static file system information.\r\n#\r\n# Use 'blkid' to print the universally unique identifier for a\r\n# device; this may be used with UUID= as a more robust way to name devices\r\n# that works even if disks are added and removed. See fstab(5).\r\n#\r\n# systemd generates mount units based on this file, see systemd.mount(5).\r\n# Please run 'systemctl daemon-reload' after making changes here.\r\n#\r\n# <file system> <mount point> <type> <options> <dump> <pass>\r\n# /dev/mapper/myssd-root / ext4 errors=remount-ro 0 1\r\nUUID=\"f352dc11-aea8-4833-838e-2560701deada\"\t/ ext4 errors=remount-ro 0 1\r\n# /boot was on /dev/sda1 during installation\r\nUUID=\"9ab7ebce-c8e2-4221-ba18-79e3ee11d70e\"\t/boot ext4 defaults 0 2\r\n# /boot/efi was on /dev/sda2 during installation\r\nUUID=375C-2F09 /boot/efi vfat umask=0077 0 1\r\n# /dev/mapper/myssd-data /data ext4 discard,noatime,nodiratime 0 2\r\nUUID=\"dfe8a1c3-f8c1-480c-ae75-524dffd4347d\"\t/data ext4 discard,noatime,nodiratime 0 2\r\n# /dev/mapper/myssd-home /home ext4 discard,noatime,nodiratime 0 2\r\nUUID=\"383ae642-5e8f-4482-874c-30c445a2b0f1\"\t/home ext4 discard,noatime,nodiratime 0 2\r\n#\r\nUUID=\"cfa8f3e5-14cf-4c09-bf26-b39a6d7bafed\" none swap sw 0 0\r\n# /dev/mapper/mydell-backup2 /backup2 ext4 noauto,user,noatime 0 2\r\nUUID=\"4d25461b-d635-47cb-bab2-b658bbbd7166\" /backup3 ext4 noauto,user,noatime,exec 0 2\r\n/dev/sr0 /media/cdrom0 udf,iso9660 user,noauto 0 0\r\n# binds\r\n/data\t\t/home/ulefr01/data\tnone bind\r\n#\r\n# /dev/sdb1 is oude /boot/efi\r\n# /dev/sdb3 /media/ulefr01/WinC ntfs-3g noauto,user,umask=000,relatime 0 0\r\n# mount als user werkt niet zelfs met setfacl op ulefr01 van /media/ulefr01 !\r\nUUID=C4BE2937BE292400 /media/ulefr01/WinC ntfs-3g noauto,rw,exec,umask=000,relatime 0 0\r\n# /dev/sdb4 /media/ulefr01/WinD ntfs-3g noauto,user,umask=000,relatime 0 0\r\n# UUID=E6DCB388DCB35193 /media/ulefr01/WinD ntfs-3g noauto,rw,exec,umask=000,relatime 0 0\r\n# /dev/sdb5 /media/ulefr01/WinE ntfs-3g noauto,user,umask=000,relatime 0 0\r\n# UUID=B204B41404B3D995 /media/ulefr01/WinE ntfs-3g noauto,rw,exec,umask=000,relatime 0 0\r\n# /dev/mapper/myssd-swap none swap sw 0 0\r\n# /dev/mapper/mydell-swap none swap sw 0 0\r\n#UUID=f51d101d-bcc2-4406-b0e5-4bd8d14b0a5c none swap sw 0 0\r\n#UUID=5d286c23-6404-48b5-b70e-46ca8f68bb06 none swap sw 0 0\r\n\r\nUUID=4D0E-9011 /stick16GB vfat noauto,user,noatime 0\t0\r\n#\r\nUUID=349dd629-7fb7-41bc-9e5e-eef9f0f514a8 /stick32GB ext4 noauto,user,noatime,exec 0\t0\r\n# UUID=51FE-C5FC /myssd2_EFI vfat noauto,user,noatime 0 \t0\r\nUUID=a59547f3-adf3-4dae-9646-ba6ddd560ce4 /myssd2_data2 ext4 noauto,user,noatime,exec 0\t0\r\nUUID=\"90b9bdd6-2458-43a0-8000-de9bf96e4a38\" /myssd2_data ext4 noauto,user,noatime,exec 0 2\r\n# UUID=02d537ed-d5f9-49b3-bbed-c372cb090078 /myssd2_data ext4 noauto,user,noatime,exec 0\t0\r\n#UUID=\"312f8c97-bf2e-4b38-9bfa-6d62750f6cbc\" /myssd2_boot ext4 noauto,user,noatime,exec 0\t0\r\n#UUID=\"0cb30de6-e30c-4946-a3b4-59e094d0edd9\" /myssd2_root ext4 noauto,user,noatime,exec 0\t0\r\n#UUID=\"0f2ce667-4f37-48c8-9b93-4878677e8098\" /myssd2_home ext4 noauto,user,noatime,exec 0\t0\r\nUUID=69D2-B18A /myexthd1_EFI vfat noauto,user,noatime 0 \t0\r\nUUID=db73a007-0730-4ef0-9ce2-1bba24039987 /myexthd1_2 ext4 noauto,user,noatime,exec 0\t0\r\nUUID=abc6cedf-ca7d-4748-ad7d-3a6f768cb0c5 /myexthd1_3 ext4 noauto,user,noatime,exec 0\t0\r\nUUID=9b3cc369-7d43-4d6f-8a87-936c404080bd /myexthd1_4 ext4 noauto,user,noatime,exec 0\t0\r\nUUID=\"a491343c-6d60-4941-b4f4-9d5697bf6cfe\" /stick64GB ext4 noauto,user,noatime\t0\t0\r\n#\r\n
\r\n\r\n", "db_count": 117 }, { "taaknaam": "Fstrim wanneer gedaan ?", "taaktext": "
sudo journalctl | grep fstrim
\r\n\r\ntoont wanneer fstrim gedaan wordt en wanneer niet
\r\n\r\nBIOS
\r\n AHCI activeren ipv IDE
\r\n
\r\nswap partitie niet op SSD
Fstab
\r\n gebruik optie noatime
setup fstrim
\r\n\r\n\r\n\r\n\r\nsudo cp /usr/share/doc/util-linux/examples/fstrim.service [[/etc/systemd/system]]
\r\n
\r\nsudo cp /usr/share/doc/util-linux/examples/fstrim.timer [[/etc/systemd/system]]
\r\n adapt [[/etc/systemd/system/fstrim.timer]]
\r\n change weekly into daily
\r\n\r\n\r\n\r\n
\r\nsudo systemctl enable fstrim.timer
\r\n\r\n\r\nsudo journalctl -u fstrim
\r\n
\r\n -- Logs begin at Wed 2018-05-02 16:10:49 CEST, end at Wed 2018-05-02 22:04:57 CE
\r\n -- No entries --
\r\n lines 1-2/2 (END)
\r\n
\r\n sudo journalctl -u fstrim
\r\n -- Logs begin at Fri 2018-05-04 06:44:49 CEST, end at Fri 2018-05-04 08:51:05 CEST. --
\r\n mei 04 06:44:52 ulefr01-inspiron systemd[1]: Starting Discard unused blocks...
\r\n mei 04 06:44:56 ulefr01-inspiron fstrim[710]: /data: 49,5 GiB (53131530240 bytes) is getrimd
\r\n mei 04 06:44:56 ulefr01-inspiron fstrim[710]: /home: 36,1 GiB (38776999936 bytes) is getrimd
\r\n mei 04 06:44:56 ulefr01-inspiron fstrim[710]: /boot: 858,9 MiB (900624384 bytes) is getrimd
\r\n mei 04 06:44:56 ulefr01-inspiron fstrim[710]: /: 36,8 GiB (39466745856 bytes) is getrimd
\r\n mei 04 06:44:56 ulefr01-inspiron systemd[1]: Started Discard unused blocks.
\r\n", "db_count": 119 }, { "taaknaam": "GPT disk", "taaktext": "sudo fstrim -v /
\r\n
\r\n sudo fstrim -v /boot
\r\n sudo fstrim -v /home
\r\n sudo fstrim -v /data
\r\n
UEFI systems :
\r\n\r\n- EFI system met partition type = 'EF00' partion vlaggen = 'boot,esp'
\r\n\r\n- EFI op windows :
\r\n\r\npartitie type = '0700' FAT32 partitie vlaggen = 'msftdata'
\r\n\r\nSome newer systems use the GUID Partition Table (GPT) format. This was specified as part of the Extensible Firmware Interface (EFI), but it can also be used on BIOS platforms if system software supports it; for example, GRUB and GNU/Linux can be used in this configuration. With this format, it is possible to reserve a whole partition for GRUB, called the BIOS Boot Partition. GRUB can then be embedded into that partition without the risk of being overwritten by other software and without being contained in a filesystem which might move its blocks around.
\r\n\r\nWhen creating a BIOS Boot Partition on a GPT system, you should make sure that it is at least 31 KiB in size. (GPT-formatted disks are not usually particularly small, so we recommend that you make it larger than the bare minimum, such as 1 MiB, to allow plenty of room for growth.) You must also make sure that it has the proper partition type. Using GNU Parted, you can set this using a command such as the following:
\r\n\r\n\r\n# parted /dev/disk set partition-number bios_grub on NIET gebruiken op UEFI systemen !\r\n
\r\n\r\nIf you are using gdisk, set the partition type to ‘0xEF02’. With partitioning programs that require setting the GUID directly, it should be ‘21686148-6449-6e6f-744e656564454649’.
\r\n\r\nCaution: Be very careful which partition you select! When GRUB finds a BIOS Boot Partition during installation, it will automatically overwrite part of it. Make sure that the partition does not contain any other data.
\r\n\r\nNote:
\r\n\r\nGparted /dev/disk hangs wanneer GPT disk zonder een bios_grub partitie in legacy mode
\r\n\r\nals grub-install correct uitgevoerd is zal de grub2 core.img plaatsen op de EF02 partitie
", "db_count": 128 }, { "taaknaam": "Gdisk tool", "taaktext": "\r\n\t\r\n\t\r\n\t\t
\r\n\t- custom 41_custom\r\n\t\t
\r\n\t\r\n\t\t\t
\r\n\t\t- sudo nano /etc/grub.d/41_custom\r\n\t\t\t
\r\n\t\t\r\n\t\t\t\t
\r\n\t\t\t- menuentry "Nieuw SystemRescue 6.0.2 " {\r\n\t\t\t\t
\r\n\t\t\t\t\r\n\t\t\t\t\t
\r\n\t\t\t\t- load_video
\r\n\t\t\t\t\t- insmod gzio
\r\n\t\t\t\t\t- insmod part_gpt
\r\n\t\t\t\t\t- insmod part_msdos
\r\n\t\t\t\t\t- insmod ext2
\r\n\t\t\t\t\t- set root=(hd0,gpt2)
\r\n\t\t\t\t\t- set root=db73a007-0730-4ef0-9ce2-1bba24039987
\r\n\t\t\t\t\t- echo 'loading linux kernel ...'
\r\n\t\t\t\t\t- linux /sysresccd/boot/x86_64/vmlinuz archisobasedir=sysresccd archisolabel=SYSRCD602 nodhcp setkmap=be dostartx copytoram
\r\n\t\t\t\t\t- echo 'loading initramfs ...'
\r\n\t\t\t\t\t- initrd /sysresccd/boot/x86_64/sysresccd.img
\r\n\t\t\t\t- }
\r\n\t\t\t
probleem met gnome desktop :
\r\n\r\nprobleem met netwerk
\r\n\r\nprobleem met lightdm of gdm3
\r\n\r\nprobleem met apt , apt-get
\r\n\r\nGa naar console mode
\r\n\r\n\t\r\n Ctrl+Alt+F4\r\n
\r\n\tkijk hoeveel plaats er over is op de Volume Groep
\r\n\tfysische volume groepen
\r\n pvs\r\n
\r\n\r\n\tvolume groepen
\r\n\r\n\t\r\n vgs\r\n
\r\n\tKoppel het volume af (hier als voorbeeld neem ik /home
)
\r\n umount /home/ulefr01/data\r\n umount /home\r\n
\r\n\tVergroot de logische volume (hier als voorbeeld van 50G
naar 80G
)
\r\n\tgebruik lvextend
, e2fsck
en resize2fs
\r\n lvextend -L 80G /dev/myssd/home\r\n e2fsck -f /dev/myssd/home\r\n resize2fs /dev/myssd/home 80G\r\n
\r\n\tKoppel het volume aan
\r\n\r\n\t\r\n mount -a\r\n
\r\n\r\n\tofwel
\r\n\r\n\t\r\n mount /dev/myssd/home /home\r\n
\r\n\tBekijk de grootte van de Logische Volume
\r\n\r\n\t\r\n df -h /home\r\n
\r\n\r\n\tVerifiëer nu de grootte van je logische volume en de grootte zou aangepast moeten zijn.
\r\n\tGa naar grafische mode
\r\n\r\n\t\r\n Ctrl+Alt+F1\r\n
\r\n\tGa naar console mode
\r\n\r\n\t\r\n Ctrl+Alt+F4\r\n
\r\n\tKoppel het volume af (hier als voorbeeld neem ik /home)
\r\n\r\n\t\r\n umount /home/ulefr01/data\r\n umount /home\r\n
\r\n\tVerklein de logische volume
\r\n\tgebruik lvreduce
, e2fsck
en resize2fs
\r\n e2fsck -f /dev/myssd/home\r\n resize2fs /dev/myssd/home 50G\r\n lvreduce -L 50G /dev/myssd/home\r\n
\r\n\r\n\tje krijgt de boodschap 'This may DESTROY your data'
\r\n\tContinue(y/n)
\r\n\tMaak eerst een backup vooraleer verder te gaan
\r\n\tJe kunt niet kleiner gaan dan je hoeveelheid data .
\r\n e2fsck -f /dev/myssd/home\r\n
\r\n\tKoppel het volume aan
\r\n\r\n\t\r\n mount -a\r\n
\r\n\r\n\tofwel
\r\n\r\n\t\r\n mount /dev/myssd/home /home\r\n
\r\n\tBekijk de grootte van de Logische Volume
\r\n\r\n\t\r\n df -h /home\r\n
\r\n\r\n\tVerifiëer nu de grootte van je logische volume en de grootte zou aangepast moeten zijn.
\r\n\tGa naar grafische mode
\r\n\r\n\t\r\n Ctrl+Alt+F1\r\n
\r\n\t⏎
", "db_count": 75 }, { "taaknaam": "LVM", "taaktext": "With lvm, you can create/expand/shrink partitions on a running system, with out any down time..if you have more than one disk, Lvm can extend over more than one disk, so it is not limited by the size of one single disk, unlike your standard partitions. You can create snapshots and revert to the snapshot at a later time, or delete the snapshot if you no longer need it.
\r\n\r\nEen partitie van het type = "Linux LVM" kan gebruikt worden voor logische volumen maar ook als "snapshot" !
\r\nEen snapshot kan een exact kopie zijn van een logische volume dat bevrozen is op een bepaald ogenblik : dit maakt het mogelijk om consistente backups te maken van logische volumen
\r\nterwijl de logische volumen in gebruik zijn !
/dev/sda6 mydell lvm2 a-- 920,68g 500,63g
\r\n\r\n\r\n\r\n
\r\n\r\n
\r\n\r\n
\r\n\r\n
\r\n\r\n
\r\n
\r\n\r\n
\r\n\r\n
\r\n\r\n
", "db_count": 125 }, { "taaknaam": "Legacy naar UEFI", "taaktext": "
zie https://blog.getreu.net/projects/legacy-to-uefi-boot/
\r\n\r\nEnable UEFI in bios.
\r\n\r\nBoot an recent Debian live system on USB or DVD.
\r\n\r\nBackup your data!
\r\n\r\nMy lecagy boot system had a 243MiB ext2 partition mounted on /boot. This partition is never encrypted. It is where the grub files and Linux kernels reside. Check by double clicking on the partition icon on the live-disk-desktop and have a look inside.
\r\n\r\n\r\n\r\n\r\n# ls -l
\r\n
\r\ntotal 21399
\r\n-rw-r--r-- 1 root root 155429 Sep 28 00:59 config-3.16-0.bpo.2-amd64
\r\ndrwxr-xr-x 3 root root 7168 Nov 5 08:03 grub
\r\n-rw-r--r-- 1 root root 15946275 Nov 5 16:28 initrd.img-3.16-0.bpo.2-amd64
\r\ndrwx------ 2 root root 12288 Nov 24 2012 lost+found
\r\n-rw-r--r-- 1 root root 2664392 Sep 28 00:59 System.map-3.16-0.bpo.2-amd64
\r\n-rw-r--r-- 1 root root 3126096 Sep 28 00:48 vmlinuz-3.16-0.bpo.2-amd64
\r\n# df -h
\r\nFilesystem Size Used Avail Use% Mounted on
\r\n...
\r\n/dev/sdb1 234M 28M 206M 13% /media/....
\r\nAs you can see in the following partition table of the Debian legacy boot system my /boot partition is number 1 (/dev/sdb1).
Although 1 is the default value for standard debian installations better check!
\r\nThe live system has identified this partition as /dev/sdb. The debian system on your harddisk could reference it differently.
\r\nPartition table of the Debian legacy boot system
\r\n\r\n\r\n\r\n
\r\n# fdisk -l /dev/sdb
\r\n...
\r\nDevice Boot Start End Blocks Id System
\r\n/dev/sdb1 * 2048 499711 44032 7 HPFS/NTFS/exFAT
\r\n...
\r\n/dev/sdb5 501760 976771071 488134656 83 Linux
\r\nIn legacy boot mode the /boot partition must have the boot-flag (*) set. This confirms our assumption: the /boot filesystem is on: /dev/sdb1.
\r\n\r\n\r\n# gdisk -l /dev/sdb
\r\n\r\n
\r\nGPT fdisk (gdisk) version 0.8.5Partition table scan:
\r\n
\r\nMBR: MBR only
\r\nBSD: not present
\r\nAPM: not present
\r\nGPT: not present
\r\n...
\r\nNumber Start (sector) End (sector) Size Code Name
\r\n1 2048 499711 243.0 MiB 8300 Linux filesystem
\r\n5 501760 976771071 238.2 GiB 8300 Linux filesystem
Transform the partition table from MBR to GPT with
\r\n\r\n\r\n\r\n\r\n# gdisk /dev/sdb
\r\n
optie r recovery and transformation options (experts only)
\r\noptie f load MBR and build fresh GPT from it
optie w write table to disk and exit
\r\n\r\nA good graphical tool is the Gnome Partition Editor gparted:
\r\n\r\n\r\n\r\n\r\n# gparted /dev/sdb
\r\n
\r\nShrink the /root partition to 200MB in order to free 43MB (see partition 1 below).
Create a new 43MB partition for efi using gparted with partition code EF00 (EFI system) and flag it bootable. Format the partition with a fat32 [1] filesystem (see partition 2 below).
\r\n\r\nUEFI needs additionally [2] a not formatted 1MB partition . [3] (see partition 3 below).
\r\n\r\nLeave the other partitions untouched (see partition 5 below).
\r\n\r\nHere the result:
\r\n\r\nPartition table of the Debian UEFI boot system
\r\n
\r\n\r\n\r\n# gdisk -l /dev/sdb
\r\n\r\n
\r\nGPT fdisk (gdisk) version 0.8.5Partition table scan:
\r\n\r\n
\r\nMBR: protective
\r\nBSD: not present
\r\nAPM: not present
\r\nGPT: presentFound valid GPT with protective MBR; using GPT.
\r\n\r\n
\r\nDisk /dev/sdb: 976773168 sectors, 465.8 GiB...
\r\n\r\nNumber Start (sector) End (sector) Size Code Name
\r\n
\r\n1 2048 411647 200.0 MiB 8300 Linux filesystem
\r\n2 411648 499711 43.0 MiB EF00 Efi partition
\r\n3 499712 501759 1024.0 KiB 8300 Linux filesystem
\r\n5 501760 976771071 465.5 GiB 8300 Linux filesystem
\r\n[4]
The next step differs whether the root-filesystem is encrypted or not.
\r\n\r\nMount the / (root) filesystem.
\r\n\r\nFor non-encrypted root filesystems a simple mount will do.
\r\n\r\n\r\n\r\n\r\n# mount -t ext4 /dev/sdb5 /mnt
\r\n
For encrypted root filesystems the mounting procedure can be a little tricky especially when the root filesystem resides inside a logical volume which is encrypted. This section shows how to mount and unmount an encrypted root-filesystem.
\r\n\r\n The recovery mode of the Debian 9 Stretch installer disk automates all following steps. Try this first. If it does not work follow the rest of this section.
\r\n3.2.1. Find the device and partition of the to be mounted logical volume
\r\n Connect the disk with host-system and observe the kernel messages in /var/log/syslog
\r\n\r\n\r\nroot@host-system:~# tail -f /var/log/syslog
\r\n
\r\nsd 3:0:0:0: [sdb] 976773168 512-byte logical blocks: (500 GB/465 GiB)
\r\nsd 3:0:0:0: [sdb] Write Protect is of manually.
\r\nsd 3:0:0:0: [sdb] Mode Sense: 43 00 00 00
\r\nsd 3:0:0:0: [sdb] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
\r\nsdb: sdb1 sdb2 sdb3 sdb5
\r\nsd 3:0:0:0: [sdb] Attached SCSI disk
The to be mounted device is /dev/sdb.
\r\n\r\nFind the partition
\r\n\r\n\r\n\r\n\r\nroot@host-system:~# gdisk -l /dev/sdb
\r\n
\r\nGPT fdisk (gdisk) version 0.8.5
\r\n...
\r\nNumber Start (sector) End (sector) Size Code Name
\r\n1 2048 411647 200.0 MiB 8300 Linux filesystem
\r\n2 411648 494821 43.0 MiB 0700
\r\n3 494822 501759 1024.0 KiB 8300 Linux filesystem
\r\n5 501760 976771071 465.5 GiB 8300 Linux filesystem
The to be mounted logical volume of disk-system resides on /dev/sdb5.
\r\n\r\n3.2.2. Mount encrypted logical volume
\r\n Open decryption layer.
\r\n\r\n\r\nroot@host-system:~# lvscan
\r\n\r\n
\r\nACTIVE '/dev/host-system/root' [231.03 GiB] inherit
\r\nACTIVE '/dev/host-system/swap_1' [7.20 GiB] inherit
\r\nLogical volume is not registered yet. Do so.root@host-system:~# cryptsetup luksOpen /dev/sdb5 sdb5_crypt
\r\n
\r\nEnter passphrase for /dev/sdb5:
\r\nEnter disk password.
\r\n\r\n\r\nroot@host-system:~# lvscan
\r\n
\r\ninactive '/dev/disk-system/root' [457.74 GiB] inherit
\r\ninactive '/dev/disk-system/swap_1' [7.78 GiB] inherit
\r\nACTIVE '/dev/host-system/root' [231.03 GiB] inherit
\r\nACTIVE '/dev/host-system/swap_1' [7.20 GiB] inherit
\r\nLogical volume of disk-system`is registered now. It contains one `root partition (line 1) and and one swap partition (line 2).
Activate logical volumes
\r\n\r\n\r\n\r\n\r\nroot@host-system:~# lvchange -a y disk-system
\r\n
\r\nCheck success.
\r\n\r\n\r\nroot@host-system:~# lvscan
\r\n
\r\nACTIVE '/dev/disk-system/root' [457.74 GiB] inherit
\r\nACTIVE '/dev/disk-system/swap_1' [7.78 GiB] inherit
\r\nACTIVE '/dev/host-system/root' [231.03 GiB] inherit
\r\nACTIVE '/dev/host-system/swap_1' [7.20 GiB] inherit
\r\n\r\n\r\nroot@host-system:~# ls /dev/mapper
\r\n
\r\ncontrol disksystem-root disksystem-swap_1 hostsystem-root hostsystem-swap_1 mymapper sdb5_crypt
\r\nMount logical volume
\r\n\r\n\r\nroot@host-system:~# mount -t ext4 /dev/mapper/disksystem-root /mnt
\r\n
\r\n
Check success.
\r\n\r\n\r\n\r\n\r\nroot@host-system:~# ls /mnt
\r\n
\r\nbin etc initrd.img.old lib64 mnt proc sbin sys var
\r\nboot home lib lost+found mnt2 root selinux tmp vmlinuz
\r\ndev initrd.img lib32 media opt run srv usr vmlinuz.old
3.2.3. Unmount encrypted logical volume
\r\n This subsection is only for completeness. Skip it.
\r\n\r\n\r\nroot@host-system:~# umount /mnt
\r\n\r\nroot@host-system:~# lvscan
\r\n\r\n
\r\nACTIVE '/dev/disk-system/root' [457.74 GiB] inherit
\r\nACTIVE '/dev/disk-system/swap_1' [7.78 GiB] inherit
\r\nACTIVE '/dev/host-system/root' [231.03 GiB] inherit
\r\nACTIVE '/dev/host-system/swap_1' [7.20 GiB] inheritroot@host-system:~# lvchange -a n disk-system
\r\n\r\n
\r\nroot@host-system:~# lvscan
\r\ninactive '/dev/disk-system/root' [457.74 GiB] inherit
\r\ninactive '/dev/disk-system/swap_1' [7.78 GiB] inherit
\r\nACTIVE '/dev/host-system/root' [231.03 GiB] inherit
\r\nACTIVE '/dev/host-system/swap_1' [7.20 GiB] inheritroot@host-system:~# cryptsetup luksClose sdb5_crypt
\r\n
\r\nroot@host-system:~# lvscan
\r\nACTIVE '/dev/host-system/root' [231.03 GiB] inherit
\r\nACTIVE '/dev/host-system/swap_1' [7.20 GiB] inherit
Either this way…
\r\n\r\n\r\n\r\n\r\n# mount /dev/sdb1 /mnt/boot
\r\n\r\n
\r\n# mount /dev/sdb2 /mnt/boot/efi# for i in /dev /dev/pts /proc /sys /sys/firmware/efi/efivars /run; do sudo mount -B $i /mnt$i; done
\r\n\r\n
\r\n# chroot /mnt /bin/bash
\r\n
\r\nor this way, both commands do the same…# mount /dev/sdb1 /mnt/boot
\r\n\r\n
\r\n# mount /dev/sdb2 /mnt/boot/efi
\r\n# mount --bind /sys /mnt/sys
\r\n# mount --bind /proc /mnt/proc
\r\n# mount --bind /dev /mnt/dev
\r\n# mount --bind /dev/pts /mnt/dev/pts
\r\nInternet access
\r\nFor internet access inside chroot:# cp /etc/resolv.conf /mnt/etc/resolv.conf
\r\n\r\nprobleem : efi variabelen are not supported (modprobe efivars niet geladen of missing efivars in /sys/firmware/efi/efivars)
\r\n\r\ngrub-install --force-extra-removable --target=x86_64-efi /dev/sda --recheck
\r\n
Update the entries in /mnt/etc/fstab to reflect the partition changes above. Compare the UUID’s there with the ones listed here:
\r\n\r\n\r\n\r\n\r\n# ls /dev/disk/by-uuid
\r\n
\r\n
Add the new UEFI partition (see last line in /etc/fstab below) in order to get it mounted permanently on /boot/efi.
\r\n\r\n\r\n\r\n\r\n# cat /mnt/etc/fstab
\r\n
\r\n# <file system> <mount point> <type> <options> <dump> <pass>
\r\n/dev/mapper/koobue1-root / ext4 errors=remount-ro 0 1
\r\n# /boot was on /dev/sdb1 during installation
\r\nUUID=040cdd12-8e45-48bd-822e-7b73ef9fa09f /boot ext2 defaults 0 2
\r\n/dev/mapper/koobue1-swap_1 none swap sw 0 0
\r\n/dev/sr0 /media/cdrom0 udf,iso9660 user,noauto 0 0
\r\n#Jens: tmpfs added for SSD
\r\ntmpfs /tmp tmpfs defaults,nodev,nosuid,size=500m 0 0
\r\ntmpfs /var/lock tmpfs defaults,nodev,nosuid,noexec,mode=1777,size=100m 0 0
\r\ntmpfs /var/run tmpfs defaults,nodev,nosuid,noexec,mode=0775,size=100m 0 0
\r\nUUID=19F0-4372 /boot/efi vfat defaults 0 2
\r\n
I use /dev/mapper for the encrypted file system and tmpfs because I have an SSD disk.
\r\n\r\n5.1. Preparation
\r\n\r\nEnter with:
\r\n\r\n\r\n\r\n\r\n# chroot /mnt
\r\n
\r\n
Check
\r\n\r\n\r\n\r\n\r\n# cat /etc/fstab
\r\n
\r\n
for not yet mounted entries and mount them manually e.g.
\r\n\r\n\r\n\r\n\r\n# mount /tmp
\r\n
\r\n# mount /run
\r\n# mount /var/lock
\r\n...
\r\n\r\n\r\n# apt-get remove grub-pc
\r\n
\r\n# apt-get install grub-efi
\r\n# grub-install /dev/sdb
\r\n
Check presence of the efi file:
\r\n\r\n\r\n\r\n\r\n# file /boot/efi/EFI/debian/grubx64.efi
\r\n
\r\n/boot/efi/EFI/debian/grubx64.efi: PE32+ executable (EFI application) x86-64 (stripped to external PDB), for MS Windows
\r\n
A Debian entry should be listed here:
\r\n\r\n\r\n\r\n\r\n# efibootmgr
\r\n
\r\nBootCurrent: 0000
\r\nTimeout: 0 seconds
\r\nBootOrder: 0000,2001,2002,2003
\r\nBoot0000* debian
\r\nBoot2001* EFI USB Device
\r\nBoot2002* EFI DVD/CDROM
\r\nBoot2003* EFI Network
\r\n
Exit chroot environment.
\r\n\r\n exit
\r\n Reboot the system.
start met Ventoy usb stick
\r\n\r\ndebian-live 10.9.0
\r\n\r\nlive Cd
\r\n\r\nrestore (restfs, restdir) wordt ook toegelaten met deze python programmas
", "db_count": 154 }, { "taaknaam": "MySSDs", "taaktext": "Mydell Latitude E5440
\r\n\r\nSSD4 SK-Hynix 128 GB koppelpunt
\r\n\r\npartitie 1 /myssd4
\r\n\r\nSSD3 Samsung 860 1 TB
\r\n\r\npartitie 1 /boot
\r\n\r\npartitie 2 EFI Systeem
\r\n\r\npartitie 4 root /
\r\n\r\npartitie 5 /home
\r\n\r\npartitie 6 /data
\r\n\r\npartitie 7 swap
\r\n\r\npartitie 8 vg = myssd3 579,59 GB
\r\n\r\nlv = backup3 579 GB
\r\n\r\n\r\n\r\n
Mydell Inspiron 15
\r\n\r\nSSD1 Crucial MX500 500 GB
\r\n\r\npartitie 3 vg = myssd
\r\n\r\nlvs = root, home, data
\r\n\r\nHDD ST2000 2 TB
\r\n\r\npartitie 6 vg = mydell
\r\n\r\nlvs = backup, backup2
\r\n\r\n\r\n\r\n
Externe harde schijf SSD Crucial
\r\n\r\nSSD2 Crucial MX500 1 TB
\r\n\r\npartitie 2 465,3 GB /myssd2_data
\r\n\r\npartitie 3 465,3 GB /myssd2_data2
\r\n\r\n\r\n\r\n
Externe harde schijf SSD Netac
\r\n\r\nSSD5 Netac 1TB
\r\n\r\n", "db_count": 140 }, { "taaknaam": "NetworkManager.conf", "taaktext": "
oorspronkelijk :
\r\n\r\n\r\n\r\n
\r\n[main]\r\nplugins=ifupdown,keyfile\r\n \r\n[ifupdown]\r\nmanaged=false
\r\n\r\naanpassen naar :
\r\n\r\n\r\n\r\n
\r\n[main]\r\nplugins=ifupdown,keyfile\r\n \r\n[ifupdown]\r\nmanaged=true
\r\n\r\n/etc/network/interfaces interfaces
\r\n\r\nsystemctl restart NetworkManager
\r\n\r\n", "db_count": 110 }, { "taaknaam": "Opstarten bootable usb stick", "taaktext": "
Opstarten usb systemrescue of met de Ventoy USB drive
\r\n\r\nOpstarten usb debian
\r\n\r\n
\r\n\r\nfsarchiver
\r\n\r\nchroot
\r\n\r\n", "db_count": 142 }, { "taaknaam": "Probleem pakket bij upgrade", "taaktext": "
voorbeeld : probleem met upgrade thunderbird door bug
\r\n\r\nremove pakket
\r\n\r\ninstalleer oudere versie
\r\n\r\nzet pakket op hold zodat er geen upgrades meer plaatsvinden
\r\n\r\nsudo apt-mark showhold
\r\n\r\nsudo dpkg --get-selections
\r\n
probleem met starting thunderbird when launching an older version of thunderbird
\r\n\r\n", "db_count": 133 }, { "taaknaam": "SQLITE3", "taaktext": "
\r\n\r\n
Homepage SQLite3 zie : https://www.sqlite.org/index.html
\r\ndocumentatie zie : https://www.sqlite.org/docs.html
versie 3.30.1
\r\n\r\nCommand Line shell for sqlite3 zie : https://www.sqlite.org/cli.html
\r\n\r\nSQLite Tutorial zie : https://www.tutorialspoint.com/sqlite/index.htm
", "db_count": 126 }, { "taaknaam": "Sway Referentie Kaart", "taaktext": "\r\n\t\t\t alt + Enter \r\n\t\t\t | \r\n\t\t\t\r\n\t\t\t nieuwe terminal \r\n\t\t\t | \r\n\t\t
\r\n\t\t\t alt + h / alt + ⬅ \r\n\t\t\t | \r\n\t\t\t\r\n\t\t\t venster naar links \r\n\t\t\t | \r\n\t\t
\r\n\t\t\t alt + j / alt + ⬇ \r\n\t\t\t | \r\n\t\t\t\r\n\t\t\t venster naar beneden \r\n\t\t\t | \r\n\t\t
\r\n\t\t\t alt + k / alt + ⬆ \r\n\t\t\t | \r\n\t\t\t\r\n\t\t\t venster naar boven \r\n\t\t\t | \r\n\t\t
\r\n\t\t\t alt + l / alt + ➡ \r\n\t\t\t | \r\n\t\t\t\r\n\t\t\t venster naar rechts \r\n\t\t\t | \r\n\t\t
\r\n\t\t\t alt + a \r\n\t\t\t | \r\n\t\t\t\r\n\t\t\t venster met ouder \r\n\t\t\t | \r\n\t\t
\r\n\t\t\t alt + space \r\n\t\t\t | \r\n\t\t\t\r\n\t\t\t focus verzetten \r\n\t\t\t | \r\n\t\t
\r\n\t\t\t alt + f \r\n\t\t\t | \r\n\t\t\t\r\n\t\t\t venster naar volledig scherm \r\n\t\t\t | \r\n\t\t
\r\n\t\t\t alt + v \r\n\t\t\t | \r\n\t\t\t\r\n\t\t\t venster naar onder vertikaal (default) \r\n\t\t\t | \r\n\t\t
\r\n\t\t\t alt + b \r\n\t\t\t | \r\n\t\t\t\r\n\t\t\t venster naar rechts horizontaal \r\n\t\t\t | \r\n\t\t
\r\n\t\t\t alt + r \r\n\t\t\t | \r\n\t\t\t\r\n\t\t\t vergroten/verkleinen venster ; Enter to stop \r\n\t\t\t | \r\n\t\t
\r\n\t\t\t alt + d \r\n\t\t\t | \r\n\t\t\t\r\n\t\t\t dmenu \r\n\t\t\t | \r\n\t\t
\r\n\t\t\t alt + ⬆ + q \r\n\t\t\t | \r\n\t\t\t\r\n\t\t\t sluit venster \r\n\t\t\t | \r\n\t\t
\r\n\t\t\t alt + x \r\n\t\t\t | \r\n\t\t\t\r\n\t\t\t default \r\n\t\t\t | \r\n\t\t
\r\n\t\t\t alt + s \r\n\t\t\t | \r\n\t\t\t\r\n\t\t\t stacking \r\n\t\t\t | \r\n\t\t
\r\n\t\t\t alt + w \r\n\t\t\t | \r\n\t\t\t\r\n\t\t\t tabbed \r\n\t\t\t | \r\n\t\t
\r\n\t\t\t alt + ⬆ + h / ⬅ \r\n\t\t\t | \r\n\t\t\t\r\n\t\t\t beweeg venster naar links \r\n\t\t\t | \r\n\t\t
\r\n\t\t\t alt + ⬆ + j / ⬇ \r\n\t\t\t | \r\n\t\t\t\r\n\t\t\t beweeg venster naar onder \r\n\t\t\t | \r\n\t\t
\r\n\t\t\t alt + ⬆ + k / ⬆ \r\n\t\t\t | \r\n\t\t\t\r\n\t\t\t beweeg venster naar boven \r\n\t\t\t | \r\n\t\t
\r\n\t\t\t alt + ⬆ + l / ➡ \r\n\t\t\t | \r\n\t\t\t\r\n\t\t\t beweeg venster naar rechts \r\n\t\t\t | \r\n\t\t
\r\n\t\t\t alt + (0 – 9) \r\n\t\t\t | \r\n\t\t\t\r\n\t\t\t ga naar een ander werkplaats \r\n\t\t\t | \r\n\t\t
\r\n\t\t\t alt + ⬆ + (0 – 9) \r\n\t\t\t | \r\n\t\t\t\r\n\t\t\t verplaats venster naar ander werkplaats \r\n\t\t\t | \r\n\t\t
\r\n\t\t\t alt + ⬆ + c \r\n\t\t\t | \r\n\t\t\t\r\n\t\t\t herlaad configuratie \r\n\t\t\t | \r\n\t\t
\r\n\t\t\t alt + ⬆ + r \r\n\t\t\t | \r\n\t\t\t\r\n\t\t\t herstart sway \r\n\t\t\t | \r\n\t\t
\r\n\t\t\t alt + ⬆ + e \r\n\t\t\t | \r\n\t\t\t\r\n\t\t\t ga uit sway, afmelden \r\n\t\t\t | \r\n\t\t
arandr baobab bluefish chromium discord eid-viewer
\r\n\r\ngnome-control-center gnome-disks gnome-system-monitor gnome-tweaks
\r\n\r\nlxappearance lxrandr pavucontrol
\r\n\r\nsystem-config-printer sxiv thunar thunderbird totem zim
\r\n\r\n", "db_count": 115 }, { "taaknaam": "efibootmgr", "taaktext": "
The Linux efibootmgr command line utility is very handy when it comes to managing UEFI boot menu. It’s assumed that you have installed Linux in UEFI mode.
\r\n\r\nYou can install the efibootmgr command line utility with the following commands.
\r\n\r\nDebian/Ubuntu/Linux Mint
\r\n\r\n\r\n\r\nsudo apt install efibootmgr
\r\n
\r\n\r\nFedora, CentOS, RedHat
\r\n\r\n\r\n\r\nsudo dnf install efibootmgr
\r\n
\r\n\r\nSuSE
\r\n\r\n\r\n\r\nsudo zypper install efibootmgr
\r\n
\r\n\r\nArch Linux/Manjaro
\r\n\r\n\r\n\r\nsudo pacman -S efibootmgr
\r\n
\r\n\r\nSimply run the following command. In some Linux distributions like Debian, you need to run it with sudo
privilege.
\r\n\r\nefibootmgr
\r\n
\r\n\r\nThis command allows you to view the default boot entry (BootCurrent), boot order and all boot entries. Each boot entry is identified by a boot number in hexadecimal. The asterisk (*) means the boot entry is active.+
\r\n\r\nYou can also add -v
option to show verbose information.
\r\n\r\nefibootmgr -v
\r\n
\r\n\r\nYou can see the EFI system partition number, the partition table type (GPT), UUID of the EFI system partition and the boot loader file.
\r\n\r\nFirst, copy the current boot order. For example, my boot order is:
\r\n\r\n\r\n0013,0012,0014,0000,0001,0002,0003,000D,0011,0007,0008,0009,000A,000B,000C,000E
\r\n\r\nThen type in the following command
\r\n\r\n\r\n\r\nsudo efibootmgr -o
\r\n
\r\n\r\nAnd append the boot order to the above command.
\r\n\r\n\r\n\r\nsudo efibootmgr -o 0013,0012,0014,0000,0001,0002,0003,000D,0011,0007,0008,0009,000A,000B,000C,000E
\r\n
\r\n\r\nLet’s say you want 0012
to be the first boot entry. All you have to do is move it to the left of 0013
and press Enter.
\r\n\r\nsudo efibootmgr -o 0012,0013,0014,0000,0001,0002,0003,000D,0011,0007,0008,0009,000A,000B,000C,000E
\r\n
\r\n\r\nIf you have installed multiple Linux distributions on your computer, but one of the Linux distribution doesn’t have a UEFI boot entry, you can manually add it.
\r\n\r\nBoot into the Linux distro that doesn’t have UFEI boot entry. Then make sure it has the EFI version of GRUB boot loader installed.
\r\n\r\nDebian/Ubuntu/Linux Mint
\r\n\r\n\r\n\r\nsudo apt install grub-efi
\r\n
\r\n\r\nFedora
\r\n\r\n\r\n\r\nsudo dnf install grub2-efi-modules
\r\n
\r\n\r\nThen mount the EFI system partition (ESP) under /boot/efi/
directory. In this example, /dev/sda7
is the ESP.
\r\n\r\nsudo mount /dev/sda7 /boot/efi/
\r\n
\r\n\r\nThen install Grub boot loader to ESP.
\r\n\r\n\r\n\r\nsudo grub-install /dev/sda --target=x86_64-efi --efi-directory=/boot/efi/
\r\n
\r\n\r\nx86_64-efi
means that we are going to install Grub for UEFI firmware. The default target is i386-pc
, which is for traditional BIOS firmware.
Now, you should see a new entry in UEFI boot menu with the bootmgr
command. Under the hood, the Grub installer first installs a .efi
booloader file to /boot/efi/EFI/<label>/
directory. Usually it’s named grubx64.efi. Then it runs the following command to add a new entry in UEFI boot menu.
\r\n\r\nefibootmgr -c -d /dev/sda -p 7 -L <label> -l /EFI/<label>/grubx64.efi
\r\n
\r\n\r\nNewly added entry will be the first in boot order.
\r\n\r\nnew entry for debian
\r\n\r\n\r\n\r\nefibootmgr --create --disk=/dev/sda --part=1 --label="debian" --loader='EFI/debian/shimx64.efi'
\r\n
\r\n\r\nLet’s say you have installed multiple Linux distributions on a hard disk so you have multiple boot entries just like the above screenshot. And now you deleted a Linux distro but the boot entry is still there. To remove the respective boot entry, run:
\r\n\r\n\r\n\r\nsudo efibootmgr -b <bootnum> -B
\r\n
\r\n\r\nFor example,
\r\n\r\n\r\n\r\nsudo efibootmgr -b 0014 -B
\r\n
\r\n\r\n-b
option specify the boot number. -B
option delete that boot number.
A boot entry followed by asterisk indicates that it’s active. Otherwise it’s inactive. To set a boot entry active, run:
\r\n\r\n\r\n\r\nsudo efibootmgr -b <bootnum> -a
\r\n
\r\n\r\nTo set a boot entry inactive, run:
\r\n\r\n\r\n\r\nsudo efibootmgr -b <bootnum> -A
\r\n
\r\n\r\n", "db_count": 136 }, { "taaknaam": "herzet-interface-eth0-netwerk", "taaktext": "
\r\n#!/bin/bash\r\n# boot.log krijgt : 'Failed to start Raise network interfaces\r\n# check 'systemctl status networking.service'\r\n# ifup failed to bring up eth0\r\n# reset netwerk na Raise Network failed message\r\n#\r\n# author franz ulenaers\r\n# email ulefr01@gmail.com\r\n# datum 20211011\r\n#\r\nSETUP=\"/etc/network/interfaces.d/setup\"\r\nSETUPBKUP=\"/$USER/setup.oud\"\r\nCONF=\"/etc/NetworkManager/NetworkManager.conf\"\r\nCONFBKUP=\"/$USER/NetworkManager.oud\"\r\nRES=1\r\n# only run as root\r\nif [ \"$(id -u)\" != '0' ]\r\nthen\r\n echo \"Deze bash script \" $0 \" moet opgestart worden met root rechten (sudo \" $0 \" / su root) !\"\r\n exit $RES\r\nfi\r\nRES=2\r\n# cp $SETUPBKUP $SETUP -v\r\n# cp $CONFBKUP $CONF -v\r\necho \"=============================================================================\"\r\necho -e \"===== \\t\\tstart \\t\\033[1m\\033[4m reset-netwerk \\033[0m \\t\\t\\t=====\"\r\necho -e \"===== \\tde volgende pakketten moeten geïnstalleerd worden \\t\\t=====\"\r\necho -e \"===== \\tvoor een goede werking van deze script \\t\\t\\t=====\"\r\necho -e \"===== \\thet zijn de pakketten inxi sed en mawk ! \\t\\t\\t=====\"\r\napt install inxi sed mawk\r\ninxi -ni | grep IF: | grep speed >ttt.netwerk\r\n# cat ttt.netwerk\r\nawk '{ print $2 }' <ttt.netwerk >ttt.netwerk2\r\n# cat ttt.netwerk2\r\nnetw=$(cat ttt.netwerk2)\r\necho \"=============================================================================\"\r\nif [ $netw == 'eth0' ]\r\nthen\r\n echo -e \"===== \\tje lan interface is al eth0, er moet niks gedaan worden ! \\t\\t=====\"\r\n exit $RES\r\nfi\r\necho -e \"===== \\tje lan interface is niet eth0 maar : $netw \\t\\t=====\"\r\n\r\ncp $SETUP $SETUPBKUP -v\r\necho -e \"===== \\tje kopie van je oud bestand $SETUP is bewaard onder $SETUPBKUP =====\"\r\ncp $CONF $CONFBKUP -v\r\necho -e \"===== \\tje kopie van je oud bestand $CONF is bewaard onder $CONFBKUP =====\"\r\n\r\nmasker='s/eth0/'$netw'/1'\r\n# echo $masker\r\necho $masker >mask.sed\r\n\r\nsed -f mask.sed $SETUP >nieuw.setup\r\n\r\ncat nieuw.setup >$SETUP\r\necho \"=============================================================================\"\r\necho -e \"===== \\tje bestand \\033[1m\\033[4m $SETUP \\033[0m is aangepast \\t=====\"\r\ncat $SETUP\r\necho \"=============================================================================\"\r\nsed 's/# managed=false/managed=true/1' $CONF >nieuw.conf\r\ngevonden=$(cat nieuw.conf | grep 'managed=true')\r\n# echo 'gevonden =' $gevonden\r\nif [ -z \"$gevonden\" ];\r\nthen\r\n # echo 'gevonden is niks'\r\n sed 's/managed=false/managed=true/1' $CONF >nieuw.conf\r\nfi\r\n# cat nieuw.conf\r\ngevonden=$(cat nieuw.conf | grep 'managed=true')\r\nif [ -z \"$gevonden\" ];\r\nthen\r\n # echo 'gevonden(2) is niks'\r\n gevonden=$(cat nieuw.conf | grep '[[ifupdown]]')\r\n # echo 'gevonden3 is' $gevonden\r\n if [ -z \"$gevonden\" ];\r\n then\r\n # echo 'gevonden(3) is niks'\r\n echo '[ifupdown]' >>nieuw.conf\r\n echo 'managed=true' >>nieuw.conf\r\n else\r\n if [ \"$gevonden\" = '[main]' ]\r\n then\r\n echo '[ifupdown]' >>nieuw.conf\r\n echo 'managed=true' >>nieuw.conf\r\n else\r\n echo 'managed=true' >>nieuw.conf\r\n fi\r\n fi\r\nfi\r\ncat nieuw.conf >$CONF\r\necho -e \"===== je bestand \\033[1m\\033[4m\" $CONF \"\\033[0m is aangepast =====\"\r\ncat $CONF\r\necho \"=============================================================================\"\r\necho -e \"===== \\t\\t\\033[1m\\033[4m opkuis werkbestanden \\033[0m \\t\\t\\t\\t\\t=====\"\r\nrm nieuw.conf -v\r\nrm nieuw.setup -v\r\nrm ttt.netwerk -v\r\nrm ttt.netwerk2 -v\r\necho \"=============================================================================\"\r\necho -e '===== \\t\\t\\033[1m\\033[4mje netwerk wordt nu herstart\\033[0m \\t\\t\\t\\t====='\r\nsystemctl restart NetworkManager\r\nsystemctl restart networking\r\necho \"=============================================================================\"\r\necho -e \"===== Deze script $0 is \\033[1m\\033[4m correct \\033[0m uitgevoerd \\t=====\"\r\necho -e \"===== \\tje probleem moet nu opgelost zijn \\t\\t\\t\\t=====\"\r\necho -e \"===== \\tje kunt nu je computer \\033[1m\\033[4mrebooten\\033[0m \\t\\t\\t\\t=====\"\r\necho \"=============================================================================\"\r\necho -e \"===== \\tKuis achteraf het bestand $SETUPBKUP op ! \\t\\t=====\"\r\necho -e \"===== \\tKuis achteraf het bestand $CONFBKUP op ! \\t=====\"\r\necho -e \"===== \\teinde script \" $0 \" \\t\\t\\t=====\"\r\necho \"=============================================================================\"\r\nRES=0\r\nexit $RES\r\n
\r\n\r\n", "db_count": 105 }, { "taaknaam": "hp printer installatie", "taaktext": "
\r\nNodig :\r\n naam wifi netwerk\r\n wachtwoord wifi\r\n\r\nsudo apt install hplip hplip-gui hplip-data hplip-doc hpijs-ppds libsane-hpaio printer-driver-hpcups printer-driver-hpijs libhpmud0 ipp-usb libsane1 sane-airscan gscan2pdf\r\n\r\nals het knopje draadloos blauw licht en niet knippert dan is de printer verbonden in een netwerk\r\n\r\nreset printer\r\n druk 3 seconden op knop Draadloos em knop Annuleren\r\n het lampje draadloos moet blijven knipperen\r\n\r\nverbind printer met usb kabel aan computer\r\n\r\nip route\r\n\r\nip route | grep kernel\r\n kijk naar het ip adres 0/24\r\n\r\nnmap -v het_vorig_ip_adres 0/24\r\n(mijne was : nmap -v 192.168.223.0/24 )\r\n\r\nprinter web interface \r\n browser : localhost:60000\r\n settings\r\n admin\r\n 12345678\r\n network\r\n wireless\r\n setup wizard\r\n select wifi netwerk\r\n vul in wifi wachtwoord\r\n dhcp\r\n \r\n nmap -v 192.168.223.0/24 | grep deskjet\r\n haal ip address op\r\n\r\n browser : //het_ip_adres\r\n settings\r\n admin\r\n 12345678\r\n network\r\n wireless\r\n ipv4\r\n manual ipv4\r\n manual ip address\r\n manual subnet address\r\n manual default gateway\r\n automatic DNS\r\n APPLY\r\n\r\ncd ~/.hplip\r\nhp-setup\r\nhp-setup -i ipaddress \r\n\r\nmaak printer los van usb kabel\r\n\r\nhp-doctor\r\n\r\nhp-toolbox\r\n Actions\r\n print\r\n scan\r\n print test page\r\n View Printer and Device Information\r\n align cartridges\r\n clean printhesda\r\n open printers web page in browser\r\n visit hplip support\r\n help\r\n Status\r\n out of paper\r\n chronologische volorde van wat printer gedaan heeft \r\n Supplies\r\n kleur cartridge : level status\r\n zwart cartridge . level status\r\n Print Settings\r\n Printer Control\r\n Preferences\r\n auto refresh\r\n system tray icon\r\n \r\nscanimage -L\r\n device `hpaio:/net/DeskJet_3630_series?ip=192.168.223.3' is a Hewlett-Packard DeskJet_3630_series all-in-one\r\n\r\nkillall hp-systray\r\n\r\nhp-toolbox\r\n refresh\r\n status\r\n\r\nscanner\r\n scan\r\n xsane \r\n gscan2pdf\r\n
\r\n\r\n\r\n\r\n
", "db_count": 138 }, { "taaknaam": "installeer systemd-boot loader op debian met bootctl", "taaktext": "
titel: "systemd-boot met bootctl"
\r\n\r\nbeschrijving: "bootloader van systemd"
\r\n\r\nscreenshot: https://en.wikipedia.org/wiki/Systemd-boot#/media/File:Arch_Linux_UEFI_loader_screenshot.png
\r\n\r\ncategoriën:
\r\n\r\nVereisten
\r\n\r\nCheck je bootorder met het efibootmgr
commando
\r\n # uitvoeren van commando efibootmgr \r\n efibootmgr
\r\nDe BootCurrent order zal normaal als eerste boot om je huidig systeem op te starten op een nummer staan zoals 000n
met Boot000n
verwijzend naar Debian
.
Om de bootloader te installeren moet het pakket systemd-boot
geïnstalleerd zijn !
Installeer bootloader met het bootctl
commando (let op : root rechten zijn vereist!)
\r\n # installeer bootctl\r\n # sudo apt install systemd-boot\r\n bootctl install --esp-path=/boot/efi
\r\nAls de installatie van bootctl succesvol is moet je efibootmgr nu verwijzen naar Linux Boot Manager
als je eerste boot en debian
als je tweede boot selectie.
Creëer het bestand zz-update-system-boot
binnen de map /etc/kernel/postinst.d/
(root rechten vereist !)
\r\n #!/bin/sh\r\n set -e\r\n /usr/bin/kernel-install -v add "$1" "$2"\r\n exit 0
\r\nDeze procedure creëert kernel en initramfs images met de kernel-install
tool van het systemd
pakket (voor meer: man kernel-install)
\r\n\r\n\r\nNoot : de
\r\n-v
in/usr/bin/kernel-install -v add
mag eruit
\r\n\r\n\r\n\r\n\r\nmet -v optie wordt de werking getoond in /var/log/apt/term.log !\r\n
\r\n # maak het bestand uitvoerbaar \r\n chmod a+x /etc/kernel/postinst.d/zz-update-systemd-boot
\r\nCreëer het bestand zz-update-system-boot
binnen de map /etc/kernel/postrm.d/
(root rechten vereist !)
\r\n #!/bin/sh\r\n set -e\r\n /usr/bin/kernel-install -v remove "$1"\r\n exit 0
\r\n\r\n # maak het bestand uitvoerbaar\r\n chmod a+x /etc/kernel/postrm.d/zz-update-systemd-boot
\r\n/boot/efi/loader/loader.conf
\r\n # als voorbeeld\r\n default debian\r\n timeout 3 \r\n editor 1
\r\nVoer uit :
\r\n\r\n\r\n # voer uit om te zien wat je machine-id is op je systeem\r\n cat /etc/machine-id
\r\nuitvoer is een hexadecimaal
getal van 32 karakters en ziet eruit als volgt:
(dit als voorbeeld !)
\r\n\r\n\r\n # als voorbeeld\r\n 2af230c8d6464a7d8e64657bf5584ee3
\r\nCreëer de map /boot/efi/je-machine-id
met het mkdir
commando
\r\n # met als <je-machine-id> bovenstaand hexadecimaal getal van 32 karakters\r\n mkdir /boot/efi/2af230c8d6464a7d8e64657bf5584ee3
\r\nDoe een 'kernel-install add'
van je kernel versie
\r\n # dit is de kernel-install voor versie 5.10.0-15-amd64\r\n kernel-install -v add 5.10.0-15-amd64 initrd.img-5.10.0-15-amd64 vmlinuz-5.10.0-15-amd64 \r\n #
\r\nDoe hetzelfde voor al je andere kernel versies (zoals hierboven)
\r\n\r\nindien bovenstaand 'kernel-install add'
faalt , doe dan eerst een 'kernel-install remove'
vooraleer de 'kernel-install add'
opnieuw te doen , dit als volgt
\r\n # dit is de kernel-install voor versie 5.10.0-15-amd64\r\n kernel-install remove 5.10.0-15-amd64
\r\nDe map /boot/efi/loader/
bevat de bestanden :
loader.conf
random-seed
De map /boot/efi/loader/
bevat een map :
entries
deze map entries
bevat al de configuratiebestanden voor al je kernel versies
als voorbeeld:
\r\n\r\n\r\n # reboot\r\n reboot
\r\nJe bent nu klaar
\r\n\r\n\r\n h,7,F1 help\r\n e edit\r\n d make entry default \r\n +,t increase timeout\r\n -,T decrease timeout \r\n f reboot\r\n Esc\r\n ctrl+k clear command line in edit mode\r\n 1,2,3,4,... entry member\r\n l linux\r\n w windows
\r\nbootctl
is een procedure meegeleverd met het systemd
pakket
status
\r\n # bootctl status\r\n bootctl status
\r\n'bootctl status'
ziet er zo uit (als voorbeeld):\r\n System:\r\n Firmware: UEFI 2.40 (American Megatrends 5.11)\r\n Secure Boot: disabled\r\n Setup Mode: user\r\n Boot into FW: supported\r\n\r\nCurrent Boot Loader:\r\n Product: systemd-boot 247.3-6\r\n Features: ✓ Boot counting\r\n ✓ Menu timeout control\r\n ✓ One-shot menu timeout control\r\n ✓ Default entry control\r\n ✓ One-shot entry control\r\n ✓ Support for XBOOTLDR partition\r\n ✓ Support for passing random seed to OS\r\n ✓ Boot loader sets ESP partition information\r\n ESP: /dev/disk/by-partuuid/21d6d264-bbac-4c1a-b628-2e97a21c5182\r\n File: └─/EFI/systemd/systemd-bootx64.efi\r\n\r\nRandom Seed:\r\n Passed to OS: yes\r\n System Token: set\r\n Exists: yes\r\n\r\nAvailable Boot Loaders on ESP:\r\n ESP: /boot/efi (/dev/disk/by-partuuid/21d6d264-bbac-4c1a-b628-2e97a21>\r\n File: └─/EFI/systemd/systemd-bootx64.efi (systemd-boot 247.3-6)\r\n File: └─/EFI/BOOT/BOOTX64.EFI (systemd-boot 247.3-6)\r\n\r\nBoot Loaders Listed in EFI Variables:\r\n Title: Linux Boot Manager\r\n ID: 0x0007\r\n Status: active, boot-order\r\n Partition: /dev/disk/by-partuuid/21d6d264-bbac-4c1a-b628-2e97a21c5182\r\n File: └─/EFI/systemd/systemd-bootx64.efi\r\n\r\n Title: debian\r\n ID: 0x0002\r\n Status: active, boot-order\r\n Partition: /dev/disk/by-partuuid/21d6d264-bbac-4c1a-b628-2e97a21c5182\r\n File: └─/EFI/debian/shimx64.efi\r\n\r\n Title: usb\r\n ID: 0x0004\r\n Status: active, boot-order\r\n Partition: /dev/disk/by-partuuid/bf5282d8-e895-439e-8595-d4580486b17f\r\n File: └─/EFI/Boot/bootx64.efi\r\n\r\n Title: test\r\n ID: 0x0001\r\n Status: active, boot-order\r\n Partition: /dev/disk/by-partuuid/1cb0011a-3c55-4a8c-9437-11c6254f6f3e\r\n File: └─/EFI/debian/shimx64.efi\r\n\r\n Title: UEFI: ST2000LM003 HN-M201RAD, Partition 1\r\n ID: 0x0016\r\n Status: active, boot-order\r\n Partition: /dev/disk/by-partuuid/6b44c434-5196-49d8-b29a-31de8a4bbe34\r\n File: └─EFI/Microsoft/Boot/bootmgfw.efi\r\n\r\n Title: Windows Boot Manager\r\n ID: 0x0000\r\n Status: active, boot-order\r\n Partition: /dev/disk/by-partuuid/21d6d264-bbac-4c1a-b628-2e97a21c5182\r\n File: └─/EFI/Microsoft/Boot/bootmgfw.efi\r\n\r\n Title: UEFI: CT500MX500SSD1, Partition 1\r\n ID: 0x0017\r\n Status: active, boot-order\r\n Partition: /dev/disk/by-partuuid/21d6d264-bbac-4c1a-b628-2e97a21c5182\r\n File: └─EFI/Microsoft/Boot/bootmgfw.efi\r\n\r\n Title: debian2\r\n ID: 0x0006\r\n Status: active\r\n Partition: /dev/disk/by-partuuid/bf5282d8-e895-439e-8595-d4580486b17f\r\n File: └─/EFI/debian/shimx64.efi\r\n\r\n Title: UEFI: ST2000LM003 HN-M201RAD, Partition 1\r\n ID: 0x000A\r\n Status: active\r\n Partition: /dev/disk/by-partuuid/6b44c434-5196-49d8-b29a-31de8a4bbe34\r\n File: └─EFI/Microsoft/Boot/bootmgfw.efi\r\n\r\nBoot Loader Entries:\r\n $BOOT: /boot/efi (/dev/disk/by-partuuid/21d6d264-bbac-4c1a-b628-2e97a21>\r\n\r\nDefault Boot Loader Entry:\r\n title: Debian GNU/Linux 11 (bullseye) (5.10.0-15-amd64)\r\n id: 2af230c8d6464a7d8e64657bf5584ee3-5.10.0-15-amd64.conf\r\n source: /boot/efi/loader/entries/2af230c8d6464a7d8e64657bf5584ee3-5.10.0>\r\n version: 5.10.0-15-amd64\r\n machine-id: 2af230c8d6464a7d8e64657bf5584ee3\r\n linux: /2af230c8d6464a7d8e64657bf5584ee3/5.10.0-15-amd64/linux\r\n initrd: /2af230c8d6464a7d8e64657bf5584ee3/5.10.0-15-amd64/initrd.img-5.1>\r\n options: root=UUID=0d8f82d3-9635-4e9c-8f6e-1512f4e1b2d6 ro quiet\r\n
\r\nbootctl
met optie list
\r\n # bootctl list\r\n bootctl list
\r\n'bootctl list'
ziet er zo uit (dit als voorbeedl):\r\n Boot Loader Entries:\r\n title: Debian GNU/Linux 11 (bullseye) (5.10.0-8-amd64)\r\n id: 2af230c8d6464a7d8e64657bf5584ee3-5.10.0-8-amd64.conf\r\n source: /boot/efi/loader/entries/2af230c8d6464a7d8e64657bf5584ee3-5.10.0-8-amd64.conf\r\n version: 5.10.0-8-amd64\r\n machine-id: 2af230c8d6464a7d8e64657bf5584ee3\r\n linux: /2af230c8d6464a7d8e64657bf5584ee3/5.10.0-8-amd64/linux\r\n initrd: /2af230c8d6464a7d8e64657bf5584ee3/5.10.0-8-amd64/initrd.img-5.10.0-8-amd64\r\n options: root=UUID=0d8f82d3-9635-4e9c-8f6e-1512f4e1b2d6 ro quiet\r\n\r\n title: Debian GNU/Linux 11 (bullseye) (5.10.0-14-amd64)\r\n id: 2af230c8d6464a7d8e64657bf5584ee3-5.10.0-14-amd64.conf\r\n source: /boot/efi/loader/entries/2af230c8d6464a7d8e64657bf5584ee3-5.10.0-14-amd64.conf\r\n version: 5.10.0-14-amd64\r\n machine-id: 2af230c8d6464a7d8e64657bf5584ee3\r\n linux: /2af230c8d6464a7d8e64657bf5584ee3/5.10.0-14-amd64/linux\r\n initrd: /2af230c8d6464a7d8e64657bf5584ee3/5.10.0-14-amd64/initrd.img-5.10.0-14-amd64\r\n options: root=UUID=0d8f82d3-9635-4e9c-8f6e-1512f4e1b2d6 ro quiet\r\n\r\n title: Debian GNU/Linux 11 (bullseye) (5.10.0-15-amd64) (default)\r\n id: 2af230c8d6464a7d8e64657bf5584ee3-5.10.0-15-amd64.conf\r\n source: /boot/efi/loader/entries/2af230c8d6464a7d8e64657bf5584ee3-5.10.0-15-amd64.conf\r\n version: 5.10.0-15-amd64\r\n machine-id: 2af230c8d6464a7d8e64657bf5584ee3\r\n linux: /2af230c8d6464a7d8e64657bf5584ee3/5.10.0-15-amd64/linux\r\n initrd: /2af230c8d6464a7d8e64657bf5584ee3/5.10.0-15-amd64/initrd.img-5.10.0-15-amd64\r\n options: root=UUID=0d8f82d3-9635-4e9c-8f6e-1512f4e1b2d6 ro quiet\r\n\r\n title: Windows Boot Manager\r\n id: auto-windows\r\n source: /sys/firmware/efi/efivars/LoaderEntries-4a67b082-0a4c-41cf-b6c7-440b29bb8c4f\r\n\r\n title: Reboot Into Firmware Interface\r\n id: auto-reboot-to-firmware-setup\r\n source: /sys/firmware/efi/efivars/LoaderEntries-4a67b082-0a4c-41cf-b6c7-440b29bb8c4f\r\n
\r\ngebruik hiervoor het bootctl
commando met optie update
\r\n # bootctl update\r\n bootctl update
\r\n\r\n sudo systemctl enable systemd-boot-update # éénmalig !\r\n sudo systemctl start systemd-boot-update # éénmalig !\r\n # check status\r\n sudo systemctl status systemd-boot-update
\r\nHet is mogelijk de EFI variabele LoaderEntryDefault (in /sys/firmware/efi/efivars/) te wijzigen
\r\n\r\nDe mogelijke waarden kun je vinden in /boot/efi/loader/entries
\r\n # mogelijke waarden kun je vinden\r\n ls /boot/efi/loader/entries/
\r\noutput (dit als voorbeeld !)
\r\n\r\n\r\n 2af230c8d6464a7d8e64657bf5584ee3-5.10.0-8-amd64.conf\r\n 2af230c8d6464a7d8e64657bf5584ee3-5.10.0-14-amd64.conf\r\n 2af230c8d6464a7d8e64657bf5584ee3-5.10.0-15-amd64.conf
\r\nverander bijvoorbeeld de default waarde naar 2af230c8d6464a7d8e64657bf5584ee3-5.10.0-14-amd64.conf
Hiervoor gebruik je het bootctl
commando met de set-default
optie
\r\n # bootctl set-default ...\r\n bootctl set-default 2af230c8d6464a7d8e64657bf5584ee3-5.10.0-14-amd64.conf
\r\n\r\n rm /etc/machine-id\r\n systemd-machine-id-setup
\r\nentries aanpassen in /boot/efi/loader/entries map /boot/efi/'nieuw_machine_id'
\r\n\r\n\r\n tune2fs -U nieuw_uuid /dev/mapper/ ...\r\n # vereist eerst een : e2fsck -f /dev/mapper/....
\r\nofwel met : 'gparted /dev/sda' en selecteer partitie nieuw UUID
\r\n\r\n\r\n update-initramfs -u
\r\n\r\n efibootmgr --create --disk=/dev/sda --part=1 --label='debian' --loader='EFI/debian/shimx64.efi' \r\n
\r\nHiervoor gebruik je het bootctl
commando met de remove
optie
\r\n # indien je toch de installatie wil teniet doen\r\n bootctl remove\r\n exit
\r\n\r\n\r\n\r\nMaak dat je kunt opstarten met een andere bootloader (Grub, Refind, Lilo, ...) vooraleer je computer te herstarten.
\r\n
Gebruik de recenste systemrescuecd en start de systemrescue iso het best op in copy to RAM mode copytoram
\r\n cd /mnt\r\n mkdir root\r\n # /mnt/root wordt dan de basis map voor de chroot\r\n # mount je root partitie\r\n ...\r\n # mount je boot, boot/efi, home en data partities (indien van toepassing) onder de basis map\r\n ...\r\n # mount efivars, dev, proc, sys, run \r\n for i in proc sys run dev dev/pts sys/firmware/efi/efivars do mount -o bind /$i /mnt/root/$i; done\r\n chroot /mnt/root\r\n # doe updates binnen chroot\r\n ....\r\n # exit chroot\r\n exit \r\n #\r\n for i in sys/firmware/efi/efivars dev/pts dev sys proc run; do umount /mnt/root/$i; done\r\n #\r\n umount /mnt/root/boot/efi \r\n umount /mnt/root/boot\r\n umount /mnt/root/home \r\n umount /mnt/root/data \r\n ...\r\n umount /mnt/root\r\n ...\r\n reboot
\r\nOfwel opstarten in Grub (ook al start je systeem niet meer automatisch op in Grub !) dit als je grub nog niet weggegooid hebt van je systeem ! Boot in UEFI mode vanaf Super Grub2 Disk
\r\n\r\nZet RAID mode en LVM mode aan
\r\n\tSelecteer Manueel Grub2 proces
\r\n\tLaat Grub2 disk zoeken naar je Grub2 Configfiles
\r\n\tselecteer nog een goeie Configfile en start op
\r\n\tBij foute Configfile selectie , doe Esc en neem een andere Configfile.
\r\n\tconfer de oorspronkelijk website : link naam
\r\noorspronkelijk :
\r\n\r\n\r\n# This file describes the network interfaces available on your system\r\n# and how to activate them. For more information, see interfaces(5).\r\n\r\nsource /etc/network/interfaces.d/*\r\n\r\n# The loopback network interface\r\nauto lo\r\niface lo inet loopback
\r\n\r\naanpassen
\r\n\r\nlijn source /etc/network/interfaces.d/* in commentaar zodat setup niet aangeroepen wordt !
\r\n\r\nbekijk ethernet driver eth0 (ifconfig)
\r\n\r\nneem statisch ip adres ipv dynamisch
\r\n\r\ngebruik Wake On Lan
\r\n\r\napt install wakeonlan, etherwake
\r\n\r\nethtool enp3s0
\r\n\r\nmoet op Wake-on moet op g staan ipv d !
\r\n\r\nethtool -s enp3s0 wol g
\r\n\r\naanpassen naar :
\r\n\r\n\r\n# This file describes the network interfaces available on your system\r\n# and how to activate them. For more information, see interfaces(5).\r\n\r\n# source /etc/network/interfaces.d/*\r\n\r\n# The loopback network interface\r\nauto lo\r\niface lo inet loopback\r\n\r\n
\r\n\r\n", "db_count": 104 }, { "taaknaam": "mijn lokaal netwerk", "taaktext": "
smartphone gebruik Netwerk Scanner / Net Scan
\r\n\r\n\r\n\r\n
", "db_count": 90 }, { "taaknaam": "mount probleem", "taaktext": "
sudo dmesg toont :
\r\n\r\nar 7 23:26:17 ulefr01-inspiron kernel: [21364.039142] xhci_hcd 0000:00:14.0: Timeout while waiting for setup device command
\r\nMar 7 23:26:17 ulefr01-inspiron kernel: [21364.250385] usb 2-1: Device not responding to setup address.
\r\nMar 7 23:26:30 ulefr01-inspiron kernel: [21376.719336] usb 2-1: USB disconnect, device number 7
\r\nMar 7 23:26:42 ulefr01-inspiron kernel: [21389.371177] usb 2-1: new SuperSpeed Gen 1 USB device number 8 using xhci_hcd
\r\nMar 7 23:26:42 ulefr01-inspiron kernel: [21389.392184] usb 2-1: New USB device found, idVendor=174c, idProduct=55aa, bcdDevice= 1.00
\r\nMar 7 23:26:42 ulefr01-inspiron kernel: [21389.392194] usb 2-1: New USB device strings: Mfr=2, Product=3, SerialNumber=1
\r\nMar 7 23:26:42 ulefr01-inspiron kernel: [21389.392200] usb 2-1: Product: ASM105x
\r\nMar 7 23:26:42 ulefr01-inspiron kernel: [21389.392205] usb 2-1: Manufacturer: ASMT
\r\nMar 7 23:26:42 ulefr01-inspiron kernel: [21389.392209] usb 2-1: SerialNumber: 00000000000000000000
\r\nMar 7 23:26:42 ulefr01-inspiron kernel: [21389.400872] scsi host2: uas
\r\nMar 7 23:26:42 ulefr01-inspiron kernel: [21389.401521] scsi 2:0:0:0: Direct-Access ASMT 2115 0 PQ: 0 ANSI: 6
\r\nMar 7 23:26:42 ulefr01-inspiron kernel: [21389.402237] sd 2:0:0:0: Attached scsi generic sg2 type 0
\r\nMar 7 23:26:42 ulefr01-inspiron kernel: [21389.402319] sd 2:0:0:0: [sdc] Spinning up disk...
\r\nMar 7 23:26:42 ulefr01-inspiron mtp-probe: checking bus 2, device 8: "/sys/devices/pci0000:00/0000:00:14.0/usb2/2-1"
\r\nMar 7 23:26:42 ulefr01-inspiron mtp-probe: bus: 2, device: 8 was not an MTP device
\r\nMar 7 23:26:43 ulefr01-inspiron mtp-probe: checking bus 2, device 8: "/sys/devices/pci0000:00/0000:00:14.0/usb2/2-1"
\r\nMar 7 23:26:43 ulefr01-inspiron mtp-probe: bus: 2, device: 8 was not an MTP device
\r\nMar 7 23:26:46 ulefr01-inspiron kernel: [21390.407080] ...ready
\r\nMar 7 23:26:46 ulefr01-inspiron kernel: [21392.464264] sd 2:0:0:0: [sdc] 625142448 512-byte logical blocks: (320 GB/298 GiB)
\r\nMar 7 23:26:46 ulefr01-inspiron kernel: [21392.464372] sd 2:0:0:0: [sdc] Write Protect is off
\r\nMar 7 23:26:46 ulefr01-inspiron kernel: [21392.464564] sd 2:0:0:0: [sdc] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
\r\nMar 7 23:26:46 ulefr01-inspiron kernel: [21392.464801] sd 2:0:0:0: [sdc] Optimal transfer size 33553920 bytes
\r\nMar 7 23:26:46 ulefr01-inspiron kernel: [21392.546305] sdc: sdc1
\r\nMar 7 23:26:46 ulefr01-inspiron kernel: [21392.565111] sd 2:0:0:0: [sdc] Attached SCSI disk
\r\nMar 7 23:26:46 ulefr01-inspiron kernel: [21393.389949] EXT4-fs (sdc1): mounted filesystem with ordered data mode. Opts: errors=remount-ro
\r\nMar 7 23:26:46 ulefr01-inspiron udisksd[851]: Mounted /dev/sdc1 at /media/ulefr01/Hitachi1 on behalf of uid 1000
\r\nMar 7 23:27:43 ulefr01-inspiron kernel: [21450.359209] usb 2-1: USB disconnect, device number 8
\r\nMar 7 23:27:43 ulefr01-inspiron kernel: [21450.366354] sd 2:0:0:0: [sdc] Synchronizing SCSI cache
\r\nMar 7 23:27:43 ulefr01-inspiron udisksd[851]: Cleaning up mount point /media/ulefr01/Hitachi1 (device 8:33 no longer exists)
\r\nMar 7 23:27:44 ulefr01-inspiron kernel: [21450.603148] sd 2:0:0:0: [sdc] Synchronize Cache(10) failed: Result: hostbyte=DID_ERROR driverbyte=DRIVER_OK
\r\nMar 7 23:28:12 ulefr01-inspiron kernel: [21478.599156] usb 2-1: new SuperSpeed Gen 1 USB device number 9 using xhci_hcd
\r\nMar 7 23:28:12 ulefr01-inspiron kernel: [21478.620704] usb 2-1: New USB device found, idVendor=1f75, idProduct=0611, bcdDevice= 0.06
\r\nMar 7 23:28:12 ulefr01-inspiron kernel: [21478.620714] usb 2-1: New USB device strings: Mfr=4, Product=5, SerialNumber=6
\r\nMar 7 23:28:12 ulefr01-inspiron kernel: [21478.620720] usb 2-1: SerialNumber: 20181206
\r\nMar 7 23:28:17 ulefr01-inspiron kernel: [21483.847181] usb 2-1: Set SEL for device-initiated U1 failed.
\r\nMar 7 23:28:22 ulefr01-inspiron kernel: [21488.967176] usb 2-1: Enable of device-initiated U2 failed.
\r\nMar 7 23:28:22 ulefr01-inspiron kernel: [21488.967454] usb-storage 2-1:1.0: USB Mass Storage device detected
\r\nMar 7 23:28:22 ulefr01-inspiron kernel: [21488.968204] scsi host2: usb-storage 2-1:1.0
\r\nMar 7 23:28:22 ulefr01-inspiron mtp-probe: checking bus 2, device 9: "/sys/devices/pci0000:00/0000:00:14.0/usb2/2-1"
\r\nMar 7 23:28:22 ulefr01-inspiron mtp-probe: bus: 2, device: 9 was not an MTP device
\r\nMar 7 23:28:22 ulefr01-inspiron mtp-probe: checking bus 2, device 9: "/sys/devices/pci0000:00/0000:00:14.0/usb2/2-1"
\r\nMar 7 23:28:22 ulefr01-inspiron mtp-probe: bus: 2, device: 9 was not an MTP device
\r\nMar 7 23:28:59 ulefr01-inspiron kernel: [21526.343250] xhci_hcd 0000:00:14.0: Timeout while waiting for setup device command
\r\n
\r\n\r\n
oplossing
\r\n\r\nsudo modprobe xhci_hcd
\r\n\r\n", "db_count": 65 }, { "taaknaam": "myarchive.py", "taaktext": "
\r\n#!/usr/bin/env python3.9\r\n# -*- coding: iso-8859-1 -*-\r\n# FSArchiver is a system tool that allows you to save the contents of a\r\n# file system to a compressed archive file. The file system can be restored\r\n# on a partition which has a different size and it can be restored on a\r\n# different file system.\r\n# Unlike tar/dar, FSArchiver also creates the file system when it extracts\r\n# the data to partitions.\r\n# Everything is checksummed in the archive in order to protect the data. If\r\n# the archive is corrupt, you just lose the current file, not the whole archive.\r\n#\r\n# It is possible to make consistent backups met fsarchiver if you are using LVM !\r\n# see http://www.system-rescue-cd.org/lvm-guide-en/Making-consistent-backups-with-LVM/\r\n#\r\n# To start this GUI application , you need root rights !\r\n#\r\n\"\"\"\r\nA GUI for fsarchiver using Python3 and Gtk3.0\r\nAuthor: Franz Ulenaers\r\nVersion: 1.0\r\nDate: 2017/10/12\r\n\"\"\"\r\n\r\nimport gi, os, time, threading\r\ngi.require_version('Gtk', '3.0')\r\nfrom gi.repository import Gtk, Gdk\r\n\r\nglobal printdone, intervals\r\n\r\nprintdone = 1\r\nintervals = (\r\n ('uren', 3600),\r\n ('minuten', 60),\r\n ('seconden', 1),\r\n )\r\n\r\ndef display_time(seconds, granularity=3):\r\n result = []\r\n for name, count in intervals:\r\n value = seconds // count\r\n if value:\r\n seconds -= value * count\r\n if value == 1:\r\n name = name.rstrip('s')\r\n result.append(\"{} {}\".format(value, name))\r\n return ', '.join(result[:granularity])\r\n\r\n\r\nclass ArchiverGUI(object):\r\n def __init__(self):\r\n window = Gtk.Window()\r\n window.connect(\"destroy\", Gtk.main_quit)\r\n vbox = Gtk.VBox(homogeneous=False, spacing=3, expand=False)\r\n\r\n g = Gtk.Grid()\r\n g.set_border_width(10)\r\n g.set_row_spacing(5)\r\n g.set_column_spacing(5)\r\n vbox.add(g)\r\n\r\n offset = 0\r\n frame = self.new_frame(g, offset, 7)\r\n label = Gtk.Label()\r\n label.set_markup('<span font=\"12\" weight=\"bold\">Backup een bestandssysteem met fsarchiver</span>')\r\n g.attach(label, 0, 0, 2, 1)\r\n labels = [\"<b> Bestandsystemen te archiveren:</b>\",\r\n \"<b> Foldernaam voor gearchiveerd bestand:</b>\",\r\n \"<b> Gearchiveerd bestandsnaam:</b>\",\r\n \"<b> Compressie nummer:</b>\",\r\n \"<b> Aantal cpus/threads:</b>\",\r\n \"<b> Splitsen in aantal blokken van 1G</b>\"]\r\n for i in range(6):\r\n label = Gtk.Label()\r\n label.set_markup(labels[i])\r\n g.attach(label, 0, 1 + i, 1, 1)\r\n\r\n self.dev_list = self.get_device_labels()\r\n\r\n self.fs_to_archive = Gtk.ComboBoxText.new_with_entry()\r\n for d in self.dev_list:\r\n self.fs_to_archive.append_text(d)\r\n self.fs_to_archive.connect(\"changed\", self.set_default_archive_filename)\r\n g.attach(self.fs_to_archive, 1, 1, 1, 1)\r\n\r\n self.archive_file_path = Gtk.FileChooserButton()\r\n self.archive_file_path.set_title(\"Directory in which to save archive\")\r\n self.archive_file_path.set_current_folder(\"/\")\r\n self.archive_file_path.set_action(Gtk.FileChooserAction.SELECT_FOLDER)\r\n g.attach(self.archive_file_path, 1, 2, 1, 1)\r\n\r\n self.create_archive_filename = Gtk.Entry()\r\n g.attach(self.create_archive_filename, 1, 3, 1, 1)\r\n\r\n self.compression_level = Gtk.ComboBoxText()\r\n for i in range(1, 23):\r\n self.compression_level.append_text(str(i))\r\n g.attach(self.compression_level, 1, 4, 1, 1)\r\n\r\n self.number_of_threads = Gtk.ComboBoxText()\r\n for i in range(1, 6):\r\n self.number_of_threads.append_text(str(i))\r\n g.attach(self.number_of_threads, 1, 5, 1, 1)\r\n\r\n self.number_of_blocks = Gtk.ComboBoxText()\r\n for i in range(1, 7):\r\n self.number_of_blocks.append_text(str(i))\r\n g.attach(self.number_of_blocks, 1, 6, 1, 1)\r\n #============================\r\n\r\n offset = 8\r\n frame = self.new_frame(g, offset, 5)\r\n\r\n label = Gtk.Label()\r\n label.set_markup('<span font=\"12\" weight=\"bold\">Terugzetten gearchiveerd bestandssysteem</span>')\r\n\r\n g.attach(label, 0, offset, 2, 1)\r\n\r\n labels = [\"<b>Archiveer bestandsnaam:</b>\",\r\n \"<b>Positie in gearchiveerd bestand:</b>\",\r\n \"<b>Terugzetten van bestandssysteem:</b>\"]\r\n for i in range(3):\r\n label = Gtk.Label()\r\n label.set_markup(labels[i])\r\n g.attach(label, 0, offset + 1 + i, 1, 1)\r\n\r\n self.restore_archive_filename = Gtk.FileChooserButton()\r\n self.restore_archive_filename.set_title(\"Bestand bevat gearchiveerd bestandssysteem:\")\r\n self.restore_archive_filename.set_current_folder(\"/\")\r\n self.restore_archive_filename.connect(\"file-set\", self.show_info_window)\r\n g.attach(self.restore_archive_filename, 1, offset + 1, 1, 1)\r\n\r\n self.archive_position = Gtk.ComboBoxText.new_with_entry()\r\n self.archive_position.append_text(\"0\")\r\n g.attach(self.archive_position, 1, offset + 2, 1, 1)\r\n\r\n self.destination_filesystem = Gtk.ComboBoxText.new_with_entry()\r\n for d in self.dev_list:\r\n self.destination_filesystem.append_text(d)\r\n g.attach(self.destination_filesystem, 1, offset + 3, 1, 1)\r\n\r\n #============================\r\n\r\n offset = 13\r\n frame = self.new_frame(g, offset, 3)\r\n\r\n btn_box = Gtk.HButtonBox()\r\n frame.add(btn_box)\r\n\r\n btn_box.set_layout(Gtk.ButtonBoxStyle.SPREAD)\r\n btn = Gtk.Button.new_from_stock(Gtk.STOCK_QUIT)\r\n btn.connect(\"clicked\", Gtk.main_quit)\r\n btn_box.add(btn)\r\n btn = Gtk.Button.new_from_stock(Gtk.STOCK_EXECUTE)\r\n btn.connect(\"clicked\", self.gather_the_info)\r\n btn_box.add(btn)\r\n\r\n #============================\r\n\r\n offset = 16\r\n #frame = self.new_frame(g,offset,3)\r\n\r\n self.status_label = Gtk.Label(label=\"Hier komt de status\")\r\n #frame.add(self.status_label)\r\n g.attach(self.status_label, 0, 16, 4, 1)\r\n\r\n #============================\r\n\r\n window.add(vbox)\r\n window.show_all()\r\n\r\n self.info_window = Gtk.Dialog(\"Gearchiveerde Informatie\")\r\n c = self.info_window.get_content_area()\r\n self.archive_info = Gtk.TextView()\r\n c.add(self.archive_info)\r\n a = self.info_window.get_action_area()\r\n btn = Gtk.Button.new_from_stock(Gtk.STOCK_CLOSE)\r\n btn.connect(\"clicked\", lambda x: self.info_window.hide())\r\n a.add(btn)\r\n\r\n # ---------------------------------\r\n\r\n def display_time(seconds, granularity=3):\r\n result = []\r\n for name, count in intervals:\r\n value = seconds // count\r\n if value:\r\n seconds -= value * count\r\n if value == 1:\r\n name = name.rstrip('s')\r\n result.append(\"{} {}\".format(value, name))\r\n return ', '.join(result[:granularity])\r\n\r\n # ----------------------------------\r\n\r\n def new_frame(self, grid, top, height):\r\n frame = Gtk.Frame()\r\n # frame.set_shadow_type(Gtk.ShadowType.ETCHED_IN)\r\n grid.attach(frame, 0, top, 3, height)\r\n return frame\r\n\r\n # ---------------------------------\r\n\r\n def gather_the_info(self, widget):\r\n global printdone\r\n global display_time\r\n starttime = time.strftime('%H:%M:%S', time.localtime())\r\n\r\n target = self.fs_to_archive.get_active_text()\r\n target = target.strip()\r\n try:\r\n archive_name = self.restore_archive_filename.get_filename()\r\n except:\r\n archive_name = \"\"\r\n if target:\r\n path = self.archive_file_path.get_filename()\r\n filename = self.create_archive_filename.get_text() + \"-\" + time.strftime(\"%Y%m%d%H%M\") + \".fsa\"\r\n compression_level = self.compression_level.get_active() + 1\r\n thread_count = self.number_of_threads.get_active() + 1\r\n block_count = (self.number_of_blocks.get_active() + 1)*1000\r\n my_cmd = \"sudo fsarchiver -A -Z \" + str(compression_level) + \\\r\n \" -s \" + str(block_count) + \\\r\n \" -j \" + str(thread_count) + \" savefs \" + path + \\\r\n \"/\" + filename + \" \" + target\r\n #print (\"my_cmd = \",my_cmd)\r\n elif archive_name:\r\n position = self.archive_position.get_active_text()\r\n destination = self.destination_filesystem.get_active_text()\r\n my_cmd = \"sudo fsarchiver restfs \" + archive_name + \\\r\n \" id=\" + position + \",dest=\" + destination\r\n print (\"my_cmd = \",my_cmd)\r\n self.my_cmd = my_cmd\r\n self.archiver_busy_flag = 1\r\n t = threading.Thread(target=self.do_my_cmd)\r\n t.start()\r\n start_time = time.strftime('%H:%M:%S')\r\n num_sec = 0\r\n while self.archiver_busy_flag:\r\n while Gtk.events_pending():\r\n Gtk.main_iteration_do(False)\r\n self.status_label.set_text(\"Start: \" + start_time + \" Run time: \" + display_time(num_sec, 3) + \" running\")\r\n time.sleep(1)\r\n num_sec += 1\r\n\r\n if self.archiver_busy_flag == 0:\r\n self.status_label.set_text(\"Start: \" + start_time + \" Run time: \" + display_time(num_sec, 3) + \" Done !\")\r\n time.sleep(1)\r\n while printdone == 0:\r\n print (\"fsarchiver commando : \" + self.status_label.get_text())\r\n printdone = 1\r\n #\r\n\r\n # ---------------------------------\r\n\r\n def do_my_cmd(self):\r\n global printdone\r\n os.system(self.my_cmd)\r\n self.archiver_busy_flag = 0\r\n printdone = 0\r\n\r\n # ---------------------------------\r\n\r\n def show_info_window(self, widget):\r\n target = self.restore_archive_filename.get_filename()\r\n print (\"Gearchiveerde informatie van bestand = \", target)\r\n my_cmd = 'sudo fsarchiver archinfo ' + target + ' 2>&1'\r\n archinfo_msg = ''\r\n print (\"archinfo cmd = \", my_cmd)\r\n archinfo = os.popen(my_cmd, 'r')\r\n line = archinfo.readline()\r\n print (line)\r\n knt = 1\r\n while line:\r\n archinfo_msg = archinfo_msg + line\r\n line = archinfo.readline()\r\n print (line)\r\n knt += 1\r\n if knt == 3:\r\n words = line.split(' ')\r\n try:\r\n archive_filecount = int(words[2])\r\n for i in range(archive_filecount):\r\n self.archive_position.append_text(str(i + 100))\r\n except:\r\n continue\r\n b = self.archive_info.get_buffer()\r\n b.set_text(archinfo_msg)\r\n self.info_window.show_all()\r\n\r\n # ---------------------------------\r\n\r\n def get_device_labels(self):\r\n blkid = os.popen('sudo blkid -c /dev/null', 'r')\r\n dev_list = {}\r\n line = blkid.readline()\r\n while (line):\r\n mine = {}\r\n line = line.replace('/dev', 'DEVICE=/dev')\r\n line = line.replace(':', ' ')\r\n line = line.split(' ')\r\n for l in line:\r\n if l.strip():\r\n m = l.split('=')\r\n m[1] = m[1].replace('\"', ' ')\r\n mine[m[0]] = m[1].strip()\r\n break\r\n try:\r\n x = mine['LABEL']\r\n except:\r\n x = 'none'\r\n dev_list[mine['DEVICE']] = x\r\n line = blkid.readline()\r\n return dev_list\r\n\r\n # ---------------------------------\r\n\r\n def set_default_archive_filename(self, widget):\r\n f = self.fs_to_archive.get_active_text()\r\n self.create_archive_filename.set_text(self.dev_list[f])\r\n\r\n # ===============================\r\n\r\n\r\nif __name__ == \"__main__\":\r\n app = ArchiverGUI()\r\n Gtk.main()\r\n#!/usr/bin/env python3.9\r\n# -*- coding: iso-8859-1 -*-\r\n# FSArchiver is a system tool that allows you to save the contents of a\r\n# file system to a compressed archive file. The file system can be restored\r\n# on a partition which has a different size and it can be restored on a\r\n# different file system.\r\n# Unlike tar/dar, FSArchiver also creates the file system when it extracts\r\n# the data to partitions.\r\n# Everything is checksummed in the archive in order to protect the data. If\r\n# the archive is corrupt, you just lose the current file, not the whole archive.\r\n#\r\n# It is possible to make consistent backups met fsarchiver if you are using LVM !\r\n# see http://www.system-rescue-cd.org/lvm-guide-en/Making-consistent-backups-with-LVM/\r\n#\r\n# To start this GUI application , you need root rights !\r\n#\r\n\"\"\"\r\nA GUI for fsarchiver using Python3 and Gtk3.0\r\nAuthor: Franz Ulenaers\r\nVersion: 1.0\r\nDate: 2017/10/12\r\n\"\"\"\r\n\r\nimport gi, os, time, threading\r\ngi.require_version('Gtk', '3.0')\r\nfrom gi.repository import Gtk, Gdk\r\n\r\nglobal printdone, intervals\r\n\r\nprintdone = 1\r\nintervals = (\r\n ('uren', 3600),\r\n ('minuten', 60),\r\n ('seconden', 1),\r\n )\r\n\r\ndef display_time(seconds, granularity=3):\r\n result = []\r\n for name, count in intervals:\r\n value = seconds // count\r\n if value:\r\n seconds -= value * count\r\n if value == 1:\r\n name = name.rstrip('s')\r\n result.append(\"{} {}\".format(value, name))\r\n return ', '.join(result[:granularity])\r\n\r\n\r\nclass ArchiverGUI(object):\r\n def __init__(self):\r\n window = Gtk.Window()\r\n window.connect(\"destroy\", Gtk.main_quit)\r\n vbox = Gtk.VBox(homogeneous=False, spacing=3, expand=False)\r\n\r\n g = Gtk.Grid()\r\n g.set_border_width(10)\r\n g.set_row_spacing(5)\r\n g.set_column_spacing(5)\r\n vbox.add(g)\r\n\r\n offset = 0\r\n frame = self.new_frame(g, offset, 7)\r\n label = Gtk.Label()\r\n label.set_markup('<span font=\"12\" weight=\"bold\">Backup een bestandssysteem met fsarchiver</span>')\r\n g.attach(label, 0, 0, 2, 1)\r\n labels = [\"<b> Bestandsystemen te archiveren:</b>\",\r\n \"<b> Foldernaam voor gearchiveerd bestand:</b>\",\r\n \"<b> Gearchiveerd bestandsnaam:</b>\",\r\n \"<b> Compressie nummer:</b>\",\r\n \"<b> Aantal cpus/threads:</b>\",\r\n \"<b> Splitsen in aantal blokken van 1G</b>\"]\r\n for i in range(6):\r\n label = Gtk.Label()\r\n label.set_markup(labels[i])\r\n g.attach(label, 0, 1 + i, 1, 1)\r\n\r\n self.dev_list = self.get_device_labels()\r\n\r\n self.fs_to_archive = Gtk.ComboBoxText.new_with_entry()\r\n for d in self.dev_list:\r\n self.fs_to_archive.append_text(d)\r\n self.fs_to_archive.connect(\"changed\", self.set_default_archive_filename)\r\n g.attach(self.fs_to_archive, 1, 1, 1, 1)\r\n\r\n self.archive_file_path = Gtk.FileChooserButton()\r\n self.archive_file_path.set_title(\"Directory in which to save archive\")\r\n self.archive_file_path.set_current_folder(\"/\")\r\n self.archive_file_path.set_action(Gtk.FileChooserAction.SELECT_FOLDER)\r\n g.attach(self.archive_file_path, 1, 2, 1, 1)\r\n\r\n self.create_archive_filename = Gtk.Entry()\r\n g.attach(self.create_archive_filename, 1, 3, 1, 1)\r\n\r\n self.compression_level = Gtk.ComboBoxText()\r\n for i in range(1, 23):\r\n self.compression_level.append_text(str(i))\r\n g.attach(self.compression_level, 1, 4, 1, 1)\r\n\r\n self.number_of_threads = Gtk.ComboBoxText()\r\n for i in range(1, 6):\r\n self.number_of_threads.append_text(str(i))\r\n g.attach(self.number_of_threads, 1, 5, 1, 1)\r\n\r\n self.number_of_blocks = Gtk.ComboBoxText()\r\n for i in range(1, 7):\r\n self.number_of_blocks.append_text(str(i))\r\n g.attach(self.number_of_blocks, 1, 6, 1, 1)\r\n #============================\r\n\r\n offset = 8\r\n frame = self.new_frame(g, offset, 5)\r\n\r\n label = Gtk.Label()\r\n label.set_markup('<span font=\"12\" weight=\"bold\">Terugzetten gearchiveerd bestandssysteem</span>')\r\n\r\n g.attach(label, 0, offset, 2, 1)\r\n\r\n labels = [\"<b>Archiveer bestandsnaam:</b>\",\r\n \"<b>Positie in gearchiveerd bestand:</b>\",\r\n \"<b>Terugzetten van bestandssysteem:</b>\"]\r\n for i in range(3):\r\n label = Gtk.Label()\r\n label.set_markup(labels[i])\r\n g.attach(label, 0, offset + 1 + i, 1, 1)\r\n\r\n self.restore_archive_filename = Gtk.FileChooserButton()\r\n self.restore_archive_filename.set_title(\"Bestand bevat gearchiveerd bestandssysteem:\")\r\n self.restore_archive_filename.set_current_folder(\"/\")\r\n self.restore_archive_filename.connect(\"file-set\", self.show_info_window)\r\n g.attach(self.restore_archive_filename, 1, offset + 1, 1, 1)\r\n\r\n self.archive_position = Gtk.ComboBoxText.new_with_entry()\r\n self.archive_position.append_text(\"0\")\r\n g.attach(self.archive_position, 1, offset + 2, 1, 1)\r\n\r\n self.destination_filesystem = Gtk.ComboBoxText.new_with_entry()\r\n for d in self.dev_list:\r\n self.destination_filesystem.append_text(d)\r\n g.attach(self.destination_filesystem, 1, offset + 3, 1, 1)\r\n\r\n #============================\r\n\r\n offset = 13\r\n frame = self.new_frame(g, offset, 3)\r\n\r\n btn_box = Gtk.HButtonBox()\r\n frame.add(btn_box)\r\n\r\n btn_box.set_layout(Gtk.ButtonBoxStyle.SPREAD)\r\n btn = Gtk.Button.new_from_stock(Gtk.STOCK_QUIT)\r\n btn.connect(\"clicked\", Gtk.main_quit)\r\n btn_box.add(btn)\r\n btn = Gtk.Button.new_from_stock(Gtk.STOCK_EXECUTE)\r\n btn.connect(\"clicked\", self.gather_the_info)\r\n btn_box.add(btn)\r\n\r\n #============================\r\n\r\n offset = 16\r\n #frame = self.new_frame(g,offset,3)\r\n\r\n self.status_label = Gtk.Label(label=\"Hier komt de status\")\r\n #frame.add(self.status_label)\r\n g.attach(self.status_label, 0, 16, 4, 1)\r\n\r\n #============================\r\n\r\n window.add(vbox)\r\n window.show_all()\r\n\r\n self.info_window = Gtk.Dialog(\"Gearchiveerde Informatie\")\r\n c = self.info_window.get_content_area()\r\n self.archive_info = Gtk.TextView()\r\n c.add(self.archive_info)\r\n a = self.info_window.get_action_area()\r\n btn = Gtk.Button.new_from_stock(Gtk.STOCK_CLOSE)\r\n btn.connect(\"clicked\", lambda x: self.info_window.hide())\r\n a.add(btn)\r\n\r\n # ---------------------------------\r\n\r\n def display_time(seconds, granularity=3):\r\n result = []\r\n for name, count in intervals:\r\n value = seconds // count\r\n if value:\r\n seconds -= value * count\r\n if value == 1:\r\n name = name.rstrip('s')\r\n result.append(\"{} {}\".format(value, name))\r\n return ', '.join(result[:granularity])\r\n\r\n # ----------------------------------\r\n\r\n def new_frame(self, grid, top, height):\r\n frame = Gtk.Frame()\r\n # frame.set_shadow_type(Gtk.ShadowType.ETCHED_IN)\r\n grid.attach(frame, 0, top, 3, height)\r\n return frame\r\n\r\n # ---------------------------------\r\n\r\n def gather_the_info(self, widget):\r\n global printdone\r\n global display_time\r\n starttime = time.strftime('%H:%M:%S', time.localtime())\r\n\r\n target = self.fs_to_archive.get_active_text()\r\n target = target.strip()\r\n try:\r\n archive_name = self.restore_archive_filename.get_filename()\r\n except:\r\n archive_name = \"\"\r\n if target:\r\n path = self.archive_file_path.get_filename()\r\n filename = self.create_archive_filename.get_text() + \"-\" + time.strftime(\"%Y%m%d%H%M\") + \".fsa\"\r\n compression_level = self.compression_level.get_active() + 1\r\n thread_count = self.number_of_threads.get_active() + 1\r\n block_count = (self.number_of_blocks.get_active() + 1)*1000\r\n my_cmd = \"sudo fsarchiver -A -Z \" + str(compression_level) + \\\r\n \" -s \" + str(block_count) + \\\r\n \" -j \" + str(thread_count) + \" savefs \" + path + \\\r\n \"/\" + filename + \" \" + target\r\n #print (\"my_cmd = \",my_cmd)\r\n elif archive_name:\r\n position = self.archive_position.get_active_text()\r\n destination = self.destination_filesystem.get_active_text()\r\n my_cmd = \"sudo fsarchiver restfs \" + archive_name + \\\r\n \" id=\" + position + \",dest=\" + destination\r\n print (\"my_cmd = \",my_cmd)\r\n self.my_cmd = my_cmd\r\n self.archiver_busy_flag = 1\r\n t = threading.Thread(target=self.do_my_cmd)\r\n t.start()\r\n start_time = time.strftime('%H:%M:%S')\r\n num_sec = 0\r\n while self.archiver_busy_flag:\r\n while Gtk.events_pending():\r\n Gtk.main_iteration_do(False)\r\n self.status_label.set_text(\"Start: \" + start_time + \" Run time: \" + display_time(num_sec, 3) + \" running\")\r\n time.sleep(1)\r\n num_sec += 1\r\n\r\n if self.archiver_busy_flag == 0:\r\n self.status_label.set_text(\"Start: \" + start_time + \" Run time: \" + display_time(num_sec, 3) + \" Done !\")\r\n time.sleep(1)\r\n while printdone == 0:\r\n print (\"fsarchiver commando : \" + self.status_label.get_text())\r\n printdone = 1\r\n #\r\n\r\n # ---------------------------------\r\n\r\n def do_my_cmd(self):\r\n global printdone\r\n os.system(self.my_cmd)\r\n self.archiver_busy_flag = 0\r\n printdone = 0\r\n\r\n # ---------------------------------\r\n\r\n def show_info_window(self, widget):\r\n target = self.restore_archive_filename.get_filename()\r\n print (\"Gearchiveerde informatie van bestand = \", target)\r\n my_cmd = 'sudo fsarchiver archinfo ' + target + ' 2>&1'\r\n archinfo_msg = ''\r\n print (\"archinfo cmd = \", my_cmd)\r\n archinfo = os.popen(my_cmd, 'r')\r\n line = archinfo.readline()\r\n print (line)\r\n knt = 1\r\n while line:\r\n archinfo_msg = archinfo_msg + line\r\n line = archinfo.readline()\r\n print (line)\r\n knt += 1\r\n if knt == 3:\r\n words = line.split(' ')\r\n try:\r\n archive_filecount = int(words[2])\r\n for i in range(archive_filecount):\r\n self.archive_position.append_text(str(i + 100))\r\n except:\r\n continue\r\n b = self.archive_info.get_buffer()\r\n b.set_text(archinfo_msg)\r\n self.info_window.show_all()\r\n\r\n # ---------------------------------\r\n\r\n def get_device_labels(self):\r\n blkid = os.popen('sudo blkid -c /dev/null', 'r')\r\n dev_list = {}\r\n line = blkid.readline()\r\n while (line):\r\n mine = {}\r\n line = line.replace('/dev', 'DEVICE=/dev')\r\n line = line.replace(':', ' ')\r\n line = line.split(' ')\r\n for l in line:\r\n if l.strip():\r\n m = l.split('=')\r\n m[1] = m[1].replace('\"', ' ')\r\n mine[m[0]] = m[1].strip()\r\n break\r\n try:\r\n x = mine['LABEL']\r\n except:\r\n x = 'none'\r\n dev_list[mine['DEVICE']] = x\r\n line = blkid.readline()\r\n return dev_list\r\n\r\n # ---------------------------------\r\n\r\n def set_default_archive_filename(self, widget):\r\n f = self.fs_to_archive.get_active_text()\r\n self.create_archive_filename.set_text(self.dev_list[f])\r\n\r\n # ===============================\r\n\r\n\r\nif __name__ == \"__main__\":\r\n app = ArchiverGUI()\r\n Gtk.main()\r\n
\r\n\r\n", "db_count": 100 }, { "taaknaam": "myarchive_dir.py", "taaktext": "
\r\n#!/usr/bin/env python3.9\r\n# -*- coding: iso-8859-1 -*-\r\n# FSArchiver is a system tool that allows you to save the contents of a\r\n# file system to a compressed archive file. The file system can be restored\r\n# on a partition which has a different size and it can be restored on a\r\n# different file system.\r\n# Unlike tar/dar, FSArchiver also creates the file system when it extracts\r\n# the data to partitions.\r\n# Everything is checksummed in the archive in order to protect the data. If\r\n# the archive is corrupt, you just lose the current file, not the whole archive.\r\n#\r\n# It is possible to make consistent backups met fsarchiver if you are using LVM !\r\n# see http://www.system-rescue-cd.org/lvm-guide-en/Making-consistent-backups-with-LVM/\r\n#\r\n# To start this GUI application , you need root rights !\r\n#\r\n\"\"\"\r\nA GUI for fsarchiver using Python3 and Gtk3.0\r\nAuthor: Franz Ulenaers\r\nVersion: 1.0\r\nDate: 2017/10/12\r\n\"\"\"\r\nimport gi, os, time, threading\r\ngi.require_version('Gtk', '3.0')\r\nfrom gi.repository import Gtk, Gdk\r\n\r\nglobal printdone, intervals\r\n\r\nprintdone = 1\r\nintervals = (\r\n ('uren', 3600),\r\n ('minuten', 60),\r\n ('seconden', 1),\r\n )\r\n\r\ndef display_time(seconds, granularity=3):\r\n result = []\r\n for name, count in intervals:\r\n value = seconds // count\r\n if value:\r\n seconds -= value * count\r\n if value == 1:\r\n name = name.rstrip('s')\r\n result.append(\"{} {}\".format(value, name))\r\n return ', '.join(result[:granularity])\r\n\r\n\r\nclass ArchiverGUI(object):\r\n def __init__(self):\r\n window = Gtk.Window()\r\n window.connect(\"destroy\", Gtk.main_quit)\r\n vbox = Gtk.VBox(homogeneous=False, spacing=3, expand=False)\r\n\r\n g = Gtk.Grid()\r\n g.set_border_width(10)\r\n g.set_row_spacing(5)\r\n g.set_column_spacing(5)\r\n vbox.add(g)\r\n\r\n offset = 0\r\n frame = self.new_frame(g, offset, 7)\r\n label = Gtk.Label()\r\n label.set_markup('<span font=\"12\" weight=\"bold\">Backup een bestandsfolder met fsarchiver</span>')\r\n g.attach(label, 0, 0, 2, 1)\r\n labels = [\"<b> Foldernaam te archiveren:</b>\",\r\n \"<b> Foldernaam voor gearchiveerd bestand:</b>\",\r\n \"<b> Gearchiveerd bestandsnaam:</b>\",\r\n \"<b> Compressie nummer:</b>\",\r\n \"<b> Aantal cpus/threads:</b>\",\r\n \"<b> Splitsen in aantal blokken van 1G</b>\"]\r\n for i in range(6):\r\n label = Gtk.Label()\r\n label.set_markup(labels[i])\r\n g.attach(label, 0, 1 + i, 1, 1)\r\n\r\n # self.dev_list = self.get_device_labels()\r\n\r\n self.fn_to_archive = Gtk.FileChooserButton()\r\n self.fn_to_archive.set_title(\"Directory te archiveren\")\r\n self.fn_to_archive.set_current_folder(\"/\")\r\n self.fn_to_archive.set_action(Gtk.FileChooserAction.SELECT_FOLDER)\r\n g.attach(self.fn_to_archive, 1, 1, 1, 1)\r\n\r\n self.archive_file_path = Gtk.FileChooserButton()\r\n self.archive_file_path.set_title(\"Directory in which to save archive\")\r\n self.archive_file_path.set_current_folder(\"/\")\r\n self.archive_file_path.set_action(Gtk.FileChooserAction.SELECT_FOLDER)\r\n g.attach(self.archive_file_path, 1, 2, 1, 1)\r\n\r\n self.create_archive_filename = Gtk.Entry()\r\n g.attach(self.create_archive_filename, 1, 3, 1, 1)\r\n\r\n self.compression_level = Gtk.ComboBoxText()\r\n for i in range(1, 23):\r\n self.compression_level.append_text(str(i))\r\n g.attach(self.compression_level, 1, 4, 1, 1)\r\n\r\n self.number_of_threads = Gtk.ComboBoxText()\r\n for i in range(1, 6):\r\n self.number_of_threads.append_text(str(i))\r\n g.attach(self.number_of_threads, 1, 5, 1, 1)\r\n\r\n self.number_of_blocks = Gtk.ComboBoxText()\r\n for i in range(1, 7):\r\n self.number_of_blocks.append_text(str(i))\r\n g.attach(self.number_of_blocks, 1, 6, 1, 1)\r\n #============================\r\n\r\n offset = 8\r\n frame = self.new_frame(g, offset, 5)\r\n\r\n label = Gtk.Label()\r\n label.set_markup('<span font=\"12\" weight=\"bold\">Terugzetten gearchiveerd bestandssysteem</span>')\r\n\r\n g.attach(label, 0, offset, 2, 1)\r\n\r\n labels = [\"<b>Archiveer bestandsnaam:</b>\",\r\n \"<b>Terugzetten naar foldernaam:</b>\"]\r\n for i in range(2):\r\n label = Gtk.Label()\r\n label.set_markup(labels[i])\r\n g.attach(label, 0, offset + 1 + i, 1, 1)\r\n\r\n self.restore_archive_filename = Gtk.FileChooserButton()\r\n self.restore_archive_filename.set_title(\"Bestand bevat gearchiveerd bestandssysteem:\")\r\n self.restore_archive_filename.set_current_folder(\"/\")\r\n self.restore_archive_filename.connect(\"file-set\", self.show_info_window)\r\n g.attach(self.restore_archive_filename, 1, offset + 1, 1, 1)\r\n\r\n # self.archive_position = Gtk.ComboBoxText.new_with_entry()\r\n # self.archive_position.append_text(\"0\")\r\n # g.attach(self.archive_position, 1, offset + 2, 1, 1)\r\n\r\n self.destination_filesystem = Gtk.FileChooserButton()\r\n self.destination_filesystem.set_title(\"Directory in which to save archive\")\r\n self.destination_filesystem.set_current_folder(\"/\")\r\n self.destination_filesystem.set_action(Gtk.FileChooserAction.SELECT_FOLDER)\r\n g.attach(self.destination_filesystem, 1, offset + 2, 1, 1)\r\n #============================\r\n\r\n offset = 13\r\n frame = self.new_frame(g, offset, 3)\r\n\r\n btn_box = Gtk.HButtonBox()\r\n frame.add(btn_box)\r\n\r\n btn_box.set_layout(Gtk.ButtonBoxStyle.SPREAD)\r\n btn = Gtk.Button.new_from_stock(Gtk.STOCK_QUIT)\r\n btn.connect(\"clicked\", Gtk.main_quit)\r\n btn_box.add(btn)\r\n btn = Gtk.Button.new_from_stock(Gtk.STOCK_EXECUTE)\r\n btn.connect(\"clicked\", self.gather_the_info)\r\n btn_box.add(btn)\r\n\r\n #============================\r\n\r\n offset = 16\r\n #frame = self.new_frame(g,offset,3)\r\n\r\n self.status_label = Gtk.Label(label=\"Hier komt de status\")\r\n #frame.add(self.status_label)\r\n g.attach(self.status_label, 0, 16, 4, 1)\r\n\r\n #============================\r\n\r\n window.add(vbox)\r\n window.show_all()\r\n\r\n self.info_window = Gtk.Dialog(\"Gearchiveerde Informatie\")\r\n c = self.info_window.get_content_area()\r\n self.archive_info = Gtk.TextView()\r\n c.add(self.archive_info)\r\n a = self.info_window.get_action_area()\r\n btn = Gtk.Button.new_from_stock(Gtk.STOCK_CLOSE)\r\n btn.connect(\"clicked\", lambda x: self.info_window.hide())\r\n a.add(btn)\r\n\r\n # ---------------------------------\r\n\r\n def display_time(seconds, granularity=3):\r\n result = []\r\n for name, count in intervals:\r\n value = seconds // count\r\n if value:\r\n seconds -= value * count\r\n if value == 1:\r\n name = name.rstrip('s')\r\n result.append(\"{} {}\".format(value, name))\r\n return ', '.join(result[:granularity])\r\n\r\n # ----------------------------------\r\n\r\n def new_frame(self, grid, top, height):\r\n frame = Gtk.Frame()\r\n # frame.set_shadow_type(Gtk.ShadowType.ETCHED_IN)\r\n grid.attach(frame, 0, top, 3, height)\r\n return frame\r\n\r\n # ---------------------------------\r\n\r\n def gather_the_info(self, widget):\r\n global printdone\r\n global display_time\r\n starttime = time.strftime('%H:%M:%S', time.localtime())\r\n\r\n archive_name = \"\"\r\n archive_name = self.restore_archive_filename.get_filename()\r\n print(archive_name)\r\n if not(archive_name):\r\n # destination = self.destination_filesystem.get_destination()\r\n # if not(destination):\r\n path2 = self.fn_to_archive.get_filename()\r\n path = self.archive_file_path.get_filename()\r\n filename = self.create_archive_filename.get_text() + \"-\" + time.strftime(\"%Y%m%d-%Hh%M\") + \".fsa\"\r\n compression_level = self.compression_level.get_active() + 1\r\n thread_count = self.number_of_threads.get_active() + 1\r\n block_count = (self.number_of_blocks.get_active() + 1)*1000\r\n my_cmd = \"sudo fsarchiver -A -Z \" + str(compression_level) + \\\r\n \" -s \" + str(block_count) + \\\r\n \" -j \" + str(thread_count) + \" savedir \" + path + \\\r\n \"/\" + filename + \" \" + path2\r\n #print (\"my_cmd = \",my_cmd)\r\n else:\r\n destination = self.destination_filesystem.get_filename()\r\n my_cmd = \"sudo fsarchiver restdir \" + archive_name + \\\r\n \" \" + destination\r\n print (\"my_cmd = \",my_cmd)\r\n self.my_cmd = my_cmd\r\n self.archiver_busy_flag = 1\r\n t = threading.Thread(target=self.do_my_cmd)\r\n t.start()\r\n start_time = time.strftime('%H:%M:%S')\r\n num_sec = 0\r\n while self.archiver_busy_flag:\r\n while Gtk.events_pending():\r\n Gtk.main_iteration_do(False)\r\n self.status_label.set_text(\"Start: \" + start_time + \" Run time: \" + display_time(num_sec, 3) + \" running\")\r\n time.sleep(1)\r\n num_sec += 1\r\n\r\n if self.archiver_busy_flag == 0:\r\n self.status_label.set_text(\"Start: \" + start_time + \" Run time: \" + display_time(num_sec, 3) + \" Done !\")\r\n time.sleep(1)\r\n while printdone == 0:\r\n print (\"fsarchiver commando : \" + self.status_label.get_text())\r\n printdone = 1\r\n #\r\n\r\n # ---------------------------------\r\n\r\n def do_my_cmd(self):\r\n global printdone\r\n os.system(self.my_cmd)\r\n self.archiver_busy_flag = 0\r\n printdone = 0\r\n\r\n # ---------------------------------\r\n\r\n def show_info_window(self, widget):\r\n target = self.restore_archive_filename.get_filename()\r\n print (\"Gearchiveerde informatie van bestand = \", target)\r\n my_cmd = 'sudo fsarchiver archinfo ' + target + ' 2>&1'\r\n archinfo_msg = ''\r\n print (\"archinfo cmd = \", my_cmd)\r\n archinfo = os.popen(my_cmd, 'r')\r\n line = archinfo.readline()\r\n print (line)\r\n knt = 1\r\n while line:\r\n archinfo_msg = archinfo_msg + line\r\n line = archinfo.readline()\r\n print (line)\r\n knt += 1\r\n if knt == 3:\r\n words = line.split(' ')\r\n try:\r\n archive_filecount = int(words[2])\r\n for i in range(archive_filecount):\r\n self.archive_position.append_text(str(i + 100))\r\n except:\r\n continue\r\n b = self.archive_info.get_buffer()\r\n b.set_text(archinfo_msg)\r\n self.info_window.show_all()\r\n\r\n # ---------------------------------\r\n\r\n\r\n # ---------------------------------\r\n\r\n\r\n\r\n # ===============================\r\n\r\n\r\nif __name__ == \"__main__\":\r\n app = ArchiverGUI()\r\n Gtk.main()\r\n
\r\n\r\n", "db_count": 73 }, { "taaknaam": "myarchive_snapshot.py", "taaktext": "
\r\n#!/usr/bin/env python3.9\r\n# -*- coding: iso-8859-1 -*-\r\n# FSArchiver is a system tool that allows you to save the contents of a\r\n# file system to a compressed archive file. The file system can be restored\r\n# on a partition which has a different size and it can be restored on a\r\n# different file system.\r\n# Unlike tar/dar, FSArchiver also creates the file system when it extracts\r\n# the data to partitions.\r\n# Everything is checksummed in the archive in order to protect the data. If\r\n# the archive is corrupt, you just lose the current file, not the whole archive.\r\n#\r\n# It is possible to make consistent backups met fsarchiver if you are using LVM !\r\n# see http://www.system-rescue-cd.org/lvm-guide-en/Making-consistent-backups-with-LVM/\r\n#\r\n# voor de restore wordt geen snapshot gebruikt !\r\n# wanneer een snapshot gebruikt wordt dan heb je minstens 6G nodig om de logische snapshot = mysnap te cre�ren op je volumegroup !\r\n# het is dezelfde volumegroep die gebruikt wordt als voor alle te backuppen logische volumen !\r\n# To start this GUI application , you need root rights !\r\n#\r\n# be sure you have at least 6G free on /dev/myssd !!\r\n#\r\n\"\"\"\r\nA GUI for fsarchiver using Python3 and Gtk3.0\r\nAuthor: Franz Ulenaers\r\nVersion: 1.0\r\nDate: 2017/10/12\r\n\"\"\"\r\nimport gi, os, time, threading\r\ngi.require_version('Gtk', '3.0')\r\nfrom gi.repository import Gtk, Gdk\r\n\r\nglobal printdone, intervals\r\n\r\nprintdone = 1\r\nintervals = (\r\n ('uren', 3600),\r\n ('minuten', 60),\r\n ('seconden', 1),\r\n )\r\n\r\ndef display_time(seconds, granularity=3):\r\n result = []\r\n for name, count in intervals:\r\n value = seconds // count\r\n if value:\r\n seconds -= value * count\r\n if value == 1:\r\n name = name.rstrip('s')\r\n result.append(\"{} {}\".format(value, name))\r\n return ', '.join(result[:granularity])\r\n\r\n\r\nclass ArchiverGUI(object):\r\n def __init__(self):\r\n window = Gtk.Window()\r\n window.connect(\"destroy\", Gtk.main_quit)\r\n vbox = Gtk.VBox(homogeneous=False, spacing=3, expand=False)\r\n\r\n g = Gtk.Grid()\r\n g.set_border_width(10)\r\n g.set_row_spacing(5)\r\n g.set_column_spacing(5)\r\n vbox.add(g)\r\n\r\n offset = 0\r\n frame = self.new_frame(g, offset, 8)\r\n label = Gtk.Label()\r\n label.set_markup('<span font=\"12\" weight=\"bold\">Backup een bestandssysteem met fsarchiver</span>')\r\n g.attach(label, 0, 0, 2, 1)\r\n labels = [\"<b> Bestandsystemen te archiveren:</b>\",\r\n \"<b> als snapshot:</b>\",\r\n \"<b> Foldernaam voor gearchiveerd bestand:</b>\",\r\n \"<b> Gearchiveerd bestandsnaam:</b>\",\r\n \"<b> Compressie nummer:</b>\",\r\n \"<b> Aantal cpus/threads:</b>\",\r\n \"<b> Splitsen in aantal blokken van 1G</b>\"]\r\n for i in range(7):\r\n label = Gtk.Label()\r\n label.set_markup(labels[i])\r\n g.attach(label, 0, 1 + i, 1, 1)\r\n\r\n self.dev_list = self.get_device_labels()\r\n\r\n self.fs_to_archive = Gtk.ComboBoxText.new_with_entry()\r\n for d in self.dev_list:\r\n self.fs_to_archive.append_text(d)\r\n self.fs_to_archive.connect(\"changed\", self.set_default_archive_filename)\r\n g.attach(self.fs_to_archive, 1, 1, 1, 1)\r\n\r\n self.check_snapshot = Gtk.CheckButton(\"Snapshot\")\r\n self.check_snapshot.connect(\"toggled\", self.on_snapshot_toggled)\r\n self.check_snapshot.set_active(False)\r\n g.attach(self.check_snapshot, 1, 2, 1, 1)\r\n\r\n self.archive_file_path = Gtk.FileChooserButton()\r\n self.archive_file_path.set_title(\"Directory in which to save archive\")\r\n self.archive_file_path.set_current_folder(\"/\")\r\n self.archive_file_path.set_action(Gtk.FileChooserAction.SELECT_FOLDER)\r\n g.attach(self.archive_file_path, 1, 3, 1, 1)\r\n\r\n self.create_archive_filename = Gtk.Entry()\r\n g.attach(self.create_archive_filename, 1, 4, 1, 1)\r\n\r\n self.compression_level = Gtk.ComboBoxText()\r\n for i in range(1, 23):\r\n self.compression_level.append_text(str(i))\r\n g.attach(self.compression_level, 1, 5, 1, 1)\r\n\r\n self.number_of_threads = Gtk.ComboBoxText()\r\n for i in range(1, 6):\r\n self.number_of_threads.append_text(str(i))\r\n g.attach(self.number_of_threads, 1, 6, 1, 1)\r\n\r\n self.number_of_blocks = Gtk.ComboBoxText()\r\n for i in range(1, 7):\r\n self.number_of_blocks.append_text(str(i))\r\n g.attach(self.number_of_blocks, 1, 7, 1, 1)\r\n #============================\r\n\r\n offset = 8\r\n frame = self.new_frame(g, offset, 5)\r\n\r\n label = Gtk.Label()\r\n label.set_markup('<span font=\"12\" weight=\"bold\">Terugzetten gearchiveerd bestandssysteem</span>')\r\n\r\n g.attach(label, 0, offset, 2, 1)\r\n\r\n labels = [\"<b>Archiveer bestandsnaam:</b>\",\r\n \"<b>Positie in gearchiveerd bestand:</b>\",\r\n \"<b>Terugzetten van bestandssysteem:</b>\"]\r\n for i in range(3):\r\n label = Gtk.Label()\r\n label.set_markup(labels[i])\r\n g.attach(label, 0, offset + 1 + i, 1, 1)\r\n\r\n self.restore_archive_filename = Gtk.FileChooserButton()\r\n self.restore_archive_filename.set_title(\"Bestand bevat gearchiveerd bestandssysteem:\")\r\n self.restore_archive_filename.set_current_folder(\"/\")\r\n self.restore_archive_filename.connect(\"file-set\", self.show_info_window)\r\n g.attach(self.restore_archive_filename, 1, offset + 1, 1, 1)\r\n\r\n self.archive_position = Gtk.ComboBoxText.new_with_entry()\r\n self.archive_position.append_text(\"0\")\r\n g.attach(self.archive_position, 1, offset + 2, 1, 1)\r\n\r\n self.destination_filesystem = Gtk.ComboBoxText.new_with_entry()\r\n for d in self.dev_list:\r\n self.destination_filesystem.append_text(d)\r\n g.attach(self.destination_filesystem, 1, offset + 3, 1, 1)\r\n\r\n #============================\r\n\r\n offset = 13\r\n frame = self.new_frame(g, offset, 3)\r\n\r\n btn_box = Gtk.HButtonBox()\r\n frame.add(btn_box)\r\n\r\n btn_box.set_layout(Gtk.ButtonBoxStyle.SPREAD)\r\n btn = Gtk.Button.new_from_stock(Gtk.STOCK_QUIT)\r\n btn.connect(\"clicked\", Gtk.main_quit)\r\n btn_box.add(btn)\r\n btn = Gtk.Button.new_from_stock(Gtk.STOCK_EXECUTE)\r\n btn.connect(\"clicked\", self.gather_the_info)\r\n btn_box.add(btn)\r\n\r\n #============================\r\n\r\n offset = 16\r\n #frame = self.new_frame(g,offset,3)\r\n\r\n self.status_label = Gtk.Label(label=\"Hier komt de status\")\r\n #frame.add(self.status_label)\r\n g.attach(self.status_label, 0, 16, 4, 1)\r\n\r\n #============================\r\n\r\n window.add(vbox)\r\n window.show_all()\r\n\r\n self.info_window = Gtk.Dialog(\"Gearchiveerde Informatie\")\r\n c = self.info_window.get_content_area()\r\n self.archive_info = Gtk.TextView()\r\n c.add(self.archive_info)\r\n a = self.info_window.get_action_area()\r\n btn = Gtk.Button.new_from_stock(Gtk.STOCK_CLOSE)\r\n btn.connect(\"clicked\", lambda x: self.info_window.hide())\r\n a.add(btn)\r\n\r\n # ---------------------------------\r\n\r\n def on_snapshot_toggled(self, button):\r\n value = button.get_active()\r\n self.check_snapshot.set_active(value)\r\n\r\n\r\n def display_time(seconds, granularity=3):\r\n result = []\r\n for name, count in intervals:\r\n value = seconds // count\r\n if value:\r\n seconds -= value * count\r\n if value == 1:\r\n name = name.rstrip('s')\r\n result.append(\"{} {}\".format(value, name))\r\n return ', '.join(result[:granularity])\r\n\r\n # ----------------------------------\r\n\r\n def new_frame(self, grid, top, height):\r\n frame = Gtk.Frame()\r\n # frame.set_shadow_type(Gtk.ShadowType.ETCHED_IN)\r\n grid.attach(frame, 0, top, 3, height)\r\n return frame\r\n\r\n # ---------------------------------\r\n\r\n def gather_the_info(self, widget):\r\n global printdone\r\n global display_time\r\n starttime = time.strftime('%H:%M:%S', time.localtime())\r\n\r\n target = self.fs_to_archive.get_active_text()\r\n target = target.strip()\r\n try:\r\n archive_name = self.restore_archive_filename.get_filename()\r\n except:\r\n archive_name = \"\"\r\n if target:\r\n if self.check_snapshot.get_active():\r\n my_cmd0 = \"sudo lvcreate -L 6G -s -n mysnap \" + target\r\n # my_cmd2 = \"sudo lvremove -vf \" + target\r\n l=target.split(\"/\")\r\n #print(\"l 0 =\",l[0])\r\n #print(\"l 1 =\",l[1])\r\n #print(\"l 2 =\",l[2])\r\n #print(\"l 3 =\",l[3])\r\n ll = l[3].split(\"-\")\r\n target2 = \"/\"+l[1]+\"/\"+l[2]+\"/\"+ll[0]+\"-\"+\"mysnap\"\r\n my_cmd2 = \"sudo lvremove -vf \" + target2\r\n #print(\"target2 =\",target2)\r\n else:\r\n target2 = target\r\n path = self.archive_file_path.get_filename()\r\n filename = self.create_archive_filename.get_text() + \"-\" + time.strftime(\"%Y%m%d%H%M\") + \".fsa\"\r\n compression_level = self.compression_level.get_active() + 1\r\n thread_count = self.number_of_threads.get_active() + 1\r\n block_count = (self.number_of_blocks.get_active() + 1)*1000\r\n my_cmd = \"sudo fsarchiver -A -Z \" + str(compression_level) + \\\r\n \" -s \" + str(block_count) + \\\r\n \" -j \" + str(thread_count) + \" savefs \" + path + \\\r\n \"/\" + filename + \" \" + target2\r\n #print (\"my_cmd0 =\",my_cmd0)\r\n #print (\"my_cmd = \",my_cmd)\r\n #print (\"my_cmd2 =\",my_cmd2)\r\n elif archive_name:\r\n position = self.archive_position.get_active_text()\r\n destination = self.destination_filesystem.get_active_text()\r\n my_cmd = \"sudo fsarchiver restfs \" + archive_name + \\\r\n \" id=\" + position + \",dest=\" + destination\r\n\r\n #print (\"my_cmd0 = \",my_cmd0)\r\n #print (\"my_cmd = \",my_cmd)\r\n #print (\"my_cmd2 = \",my_cmd2)\r\n if self.check_snapshot.get_active():\r\n self.my_cmd = my_cmd0 + \" && \" + my_cmd + \" && \" + my_cmd2\r\n else:\r\n self.my_cmd = my_cmd\r\n\r\n print (\"my_cmd = \", self.my_cmd)\r\n self.archiver_busy_flag = 1\r\n\r\n t = threading.Thread(target=self.do_my_cmd)\r\n t.start()\r\n start_time = time.strftime('%H:%M:%S')\r\n num_sec = 0\r\n\r\n while self.archiver_busy_flag:\r\n while Gtk.events_pending():\r\n Gtk.main_iteration_do(False)\r\n self.status_label.set_text(\"Start: \" + start_time + \" Run time: \" + display_time(num_sec, 3) + \" running\")\r\n time.sleep(1)\r\n num_sec += 1\r\n\r\n if self.archiver_busy_flag == 0:\r\n self.status_label.set_text(\"Start: \" + start_time + \" Run time: \" + display_time(num_sec, 3) + \" Done !\")\r\n time.sleep(1)\r\n while printdone == 0:\r\n print (\"fsarchiver commando : \" + self.status_label.get_text())\r\n printdone = 1\r\n #\r\n\r\n # ---------------------------------\r\n\r\n def do_my_cmd(self):\r\n global printdone\r\n os.system(self.my_cmd)\r\n self.archiver_busy_flag = 0\r\n printdone = 0\r\n\r\n\r\n # ---------------------------------\r\n\r\n def show_info_window(self, widget):\r\n target = self.restore_archive_filename.get_filename()\r\n print (\"Gearchiveerde informatie van bestand = \", target)\r\n my_cmd = 'sudo fsarchiver archinfo ' + target + ' 2>&1'\r\n archinfo_msg = ''\r\n print (\"archinfo cmd = \", my_cmd)\r\n archinfo = os.popen(my_cmd, 'r')\r\n line = archinfo.readline()\r\n print (line)\r\n knt = 1\r\n while line:\r\n archinfo_msg = archinfo_msg + line\r\n line = archinfo.readline()\r\n print (line)\r\n knt += 1\r\n if knt == 3:\r\n words = line.split(' ')\r\n try:\r\n archive_filecount = int(words[2])\r\n for i in range(archive_filecount):\r\n self.archive_position.append_text(str(i + 100))\r\n except:\r\n continue\r\n b = self.archive_info.get_buffer()\r\n b.set_text(archinfo_msg)\r\n self.info_window.show_all()\r\n\r\n # ---------------------------------\r\n\r\n def get_device_labels(self):\r\n blkid = os.popen('sudo blkid -c /dev/null', 'r')\r\n dev_list = {}\r\n line = blkid.readline()\r\n while (line):\r\n mine = {}\r\n line = line.replace('/dev', 'DEVICE=/dev')\r\n line = line.replace(':', ' ')\r\n line = line.split(' ')\r\n for l in line:\r\n if l.strip():\r\n m = l.split('=')\r\n m[1] = m[1].replace('\"', ' ')\r\n mine[m[0]] = m[1].strip()\r\n break\r\n try:\r\n x = mine['LABEL']\r\n except:\r\n x = 'none'\r\n dev_list[mine['DEVICE']] = x\r\n line = blkid.readline()\r\n return dev_list\r\n\r\n # ---------------------------------\r\n\r\n def set_default_archive_filename(self, widget):\r\n f = self.fs_to_archive.get_active_text()\r\n self.create_archive_filename.set_text(self.dev_list[f])\r\n\r\n # ===============================\r\n\r\n\r\nif __name__ == \"__main__\":\r\n app = ArchiverGUI()\r\n Gtk.main()\r\n
\r\n\r\n", "db_count": 71 }, { "taaknaam": "setup loop device", "taaktext": "
sudo modprobe loop
\r\n\r\nmkdir /myssd2_data/tmp
\r\n\r\ndd if=/dev/zero of=/myssd2_data/tmp/test.ext4 bs=1G count=20
\r\n\r\nlosetup --find --show test.ext4
\r\n\r\nshows /dev/loop0
\r\n\r\nsudo mkfs.ext4 /dev/loop0
\r\n\r\nfsarchiver restfs myssd2_data/backup-data----.fsa id=0,dest=/dev/loop0
\r\n\r\nmkdir /myssd2_data/tmp/tmp
\r\n\r\nsudo mount /dev/loop0 tmp
\r\n\r\nls tmp/*
\r\n\r\nsudo umount tmp
\r\n\r\nrm test.ext4
\r\n\r\nlosetup -d /dev/loop0
\r\n\r\nsudo rmmod loop
", "db_count": 93 }, { "taaknaam": "signatures where invalid EXPKEYSIG xyzxyzxyz", "taaktext": "sudo apt-key list
\r\n\r\nsudo apt-key adv --keyserver keyring.debian.org --recv-keys xyzxyzxyz
\r\n\r\nexpired key
\r\n\r\ndelete key
\r\n\r\nsudo apt-key del xyzxyzxyz
\r\n\r\nkeyservers
\r\n\r\ndeb http://ftp.be.debian.org/debian/ bullseye main contrib non-free
\r\n\r\ndeb https://security.debian.org/debian-security bullseye-security main contrib non-free
\r\n\r\ndeb http://ftp.be.debian.org/debian/ bullseye-updates main contrib non-free
\r\n\r\ndeb http://ftp.be.debian.org/debian/ bullseye-backports main contrib non-free
\r\n\r\natom list
\r\n\r\nbluemail.list
\r\n\r\neid.list
\r\n\r\nexperimental.list
\r\n\r\nteams.list
\r\n\r\nteamviewer.list
\r\n\r\n", "db_count": 88 }, { "taaknaam": "tune all ext4 filesystemen", "taaktext": "
Herstart Inspiron laptop met usbstick 32 MB
\r\n\r\nselecteer systemrescue cd en opstarten in RAM mode
\r\n\r\nstartx
\r\n\r\nsettings keyboard
\r\n\r\nlayout
\r\n\r\nsystem mode afzetten
\r\n\r\nadd layout belgian
\r\n\r\nremove US keyboard
\r\n\r\nconsole
\r\n\r\ncd /mnt
\r\n\r\nmkdir home
\r\n\r\nmount /dev/mapper/myssd-home home
\r\n\r\ncd home/ulefr01/utils
\r\n\r\ncp tune_ext4 /tmp/.
\r\n\r\ncd /mnt
\r\n\r\numount home
\r\n\r\ncd /tmp
\r\n\r\nlsblk
\r\n\r\n./tune_ext4
\r\n\r\nfsck -V /dev/sda1
\r\n\r\nfsck -V /dev/sda2
\r\n\r\nmount Hitachi2
\r\n\r\numount Hitachi2
\r\n\r\nmount Crucial
\r\n\r\numount Crucial
\r\n\r\nmount Hitachi1
\r\n\r\numount Hitachi1
\r\n\r\nmount Hitachi4
\r\n\r\numount Hitachi4
\r\n\r\nmount Hitachi3
\r\n\r\numount Hitachi3
\r\n\r\nmount Netac
\r\n\r\numount Netac
\r\n\r\nmount Inateck (myssd2_data, ...)
\r\n\r\n
", "db_count": 66 }, { "taaknaam": "tune_ext4", "taaktext": "\r\n", "db_count": 63 } ]#!/bin/bash
\r\n
\r\n# tune_ext4
\r\nARGS=1
\r\nE_BADARGS=65
\r\nif [ $# -ne "$ARGS" ]
\r\nthen
\r\n echo "Usage: `basename $0` device"
\r\n exit $E_BADARGS
\r\nfi
\r\ndevice=$1
\r\necho 'tune_ext4'
\r\necho '---------'
\r\necho "device= $device"
\r\necho "doe : tune2fs -O ^has_journal $device"
\r\n# verwijder de journal en maak er een ext2 bestandensysteem
\r\ntune2fs -O ^has_journal $device
\r\necho "doe : e2fsck -f $device"
\r\n# check ext2 bestandensysteem op fouten en herstel ze
\r\ne2fsck -fy $device
\r\n# journal opties zijn :
\r\n# journal_data_ordered
\r\n# journal_data
\r\n# journal_data_writeback
\r\necho "doe : tune2fs -J size=4 -o journal_data_ordered $DEVICE"
\r\n# echo "doe : tune2fs -o journal_data_writeback $DEVICE"
\r\n# hermaak journal en maak ext3
\r\ntune2fs -J size=4 -o journal_data_ordered $device
\r\necho "doe : tune2fs -O extents,uninit_bg,dir_index,extra_isize -i 6m -c 200 -m 1 $device"
\r\n# -i 6m -c 200 -m 1 $device"
\r\n# maak een ext3 -6m om de 6 maanden hercheck bestandensysteem of -c 200 200 keren mounten vooraleer hercheck
\r\n# ipv -i 7d -c 15 -m 1 ...
\r\ntune2fs -O extents,uninit_bg,dir_index,extra_isize -i 6m -c 200 -m 1 $device
\r\necho "doe : e2fsck -pfD $device"
\r\n# maak een ext4 bestandensystemm
\r\ne2fsck -pfD $device
\r\necho "doe : e2fsck -f $device"
\r\ne2fsck -fy $device
\r\necho 'gedaan !'
\r\necho "device= $device"
\r\nexit 0